我的iPhone应用程序中有很多地方,像这样的一行:
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();
}
对于在生产应用程序中实际替换abort()的内容,我有些茫然。我不认为有任何简单的方法可以让用户的设备将错误发送回给您。这里的标准做法是什么?
最佳答案
我所做的工作取决于应用程序中正在发生的事情。如果可以回滚保存而不影响应用程序,则可以这样做。那将是非常罕见的。您更有可能希望让用户知道他们的保存失败。根据失败的原因,您可以提出重试或解释为什么无效的原因。
它基本上取决于您的应用程序以及如何最好地为用户服务。