将新的 NSManagedObject 添加到我的核心数据存储后,我尝试调用:
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
并得到以下异常(奇怪的是我没有错误,结果也是积极的!)
2013-03-15 18:32:09.753 Nick copy[28782:3407] CoreData:Ubiquity:日志文件导出期间发生异常:NSInternalInconsistencyException 保存通知内容:NSConcreteNotification 0x3891b0 {name = _NSSQLCoreTransactionStateChangeNotification; object = (URL: file://localhost/var/mobile/Applications/FCAF7FC6-7DC8-4E0B-A114-38778255CA90/Documents/MyApp.sqlite); userInfo = { "_NSSQLCoreActiveSaveRequest" = ""; "_NSSQLCoreTransactionType" = 2; "_NSSQLCoreTransientSequenceNumber" = 1; }}
我可以从“保存”方法中捕获所有异常,并且应用程序运行良好。只是想知道这是否真的可以节省,因为感觉完全不安全。
编辑:尝试删除对象时的另一个异常:
Catched Exception: Failed to process pending changes before save. The context is still dirty after 100 attempts. Typically this recursive dirtying is caused by a bad validation method, -willSave, or notification handler.