I recently updated Xcode to the new 7.0 beta.
I did the migration with the assistant but there are a few more issues.
func saveContext () {
if let moc = self.managedObjectContext {
var error: NSError? = nil
if moc.hasChanges && !moc.save() {
NSLog("Unresolved error \(error), \(error!.userInfo)")
abort()
}
}
}
On line 4 there are 4 issues: the first one is:
Binary operator '&&' cannot be applied to two Bool operands
the second one is:
Call can throw, but it is not marked with 'try' and the error is not handled
Can someone please help me?
Here is some code that should do the trick. Remember to preceed throw statements with try and catch them.
func saveContext () {
if let moc = self.managedObjectContext {
if moc.hasChanges {
do {
try moc.save()
} catch {
NSLog("Unresolved error \(error)")
abort()
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With