【发布时间】:2011-01-16 18:56:38
【问题描述】:
我在 Apple 提供的示例代码中看到了您应该如何处理 Core Data 错误的参考。即:
NSError *error = nil;
if (![context save:&error]) {
/*
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. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
但从来没有任何例子说明你应该如何实施它。
有没有人有(或可以指出我的方向)一些实际的“生产”代码来说明上述方法。
提前致谢, 马特
【问题讨论】:
-
+1 这是一个很好的问题。
标签: iphone core-data error-handling