Reputation: 23
var error: NSError? = nil
return app.managedObjectContext!.save(&error)
It said "Cannot force unwrap value of non-optional type 'NSManagedObjectContext'"
And if i delete '!'
It said "'&' used with non-in out argument of type '()'"
And finally i delete '&'
It said "Argument passed to call that takes no arguments"
I feel hopeless.
Upvotes: 0
Views: 409
Reputation: 1903
You need to use the new syntax:
do
{
try app.managedObjectContext.save()
} catch let error as NSError {
print(error)
}
Upvotes: 1