do try catch swift 2
问题 HI i am a little confused about how to transfer if_else error handling to do try catch successfully. Here is my code. let error : NSError? if(managedObjectContext!.save()) { NSNotificationCenter.defaultCenter().postNotificationName("updateUndoState", object: nil) if error != nil { print(error?.localizedDescription) } } else { print("abort") abort() } and now i converted to swift 2.0 like this do { try managedObjectContext!.save() } catch { NSNotificationCenter.defaultCenter()