我试图save
在我的 Model 类上调用函数,但是即使它适用于 1.2,它也会在 2.1 中引发此错误:
Argument passed to call that takes no arguments
func save() -> NSError?{
var error: NSError?
self.context?.save(error) // Error: Argument passed to call that takes no arguments
return error
}
编辑:
我将代码转换为:
func save() -> NSError?{
do {
try context!.save()
} catch let error as NSError? {
print("error saving core data: \(error)")
}
}
...但现在我收到:
Missing return in a function expected to return 'NSError?'