Based on the fact a save
error should not appear in production my best advice is to follow a similar pattern.
NSError *error = nil;
if ([self.managedObjectContext save:&error] == NO) {
NSAssert(NO, @"Save should not fail");
[self showAlert];
}
- (void)showAlert {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Could Not Save Data"
message:@"There was a problem saving your data but it is not your fault. If you restart the app, you can try again. Please contact support (support@domain.com) to notify us of this issue."
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
abort();
}
Credits goes to Matthew Morey as described in NSManagedObjectContext save error.
I really like this approach since it informs the user that something bad happened.
In addition to this I will also create a log file that can be sent by email to support. In the log you will put much info as possible to investigate the error. To achieve this, for example, you could use CocoaLumberjack. Take a look also to Mailing Logs by NSSCreenCast.