新しい Xcode 7.0 ベータ版をダウンロードし、Swift 1.2 から Swift 2 への移行を行いました。移行によって明らかにコード全体が変更されたわけではありません。
if moc.hasChanges && !moc.save() {
二項演算子 '&&' は 2 つの Bool オペランドに適用できません
と
呼び出しはスローできますが、「try」とマークされておらず、エラーは処理されません
メソッドは次のようになります。
// MARK: - Core Data Saving support
func saveContext () {
if let moc = self.managedObjectContext {
var error: NSError? = nil
if moc.hasChanges && !moc.save() {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog("Unresolved error \(error), \(error!.userInfo)")
abort()
}
}
}
それを機能させる方法についてのアイデアはありますか?