Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing aborts() for unresolved errors in iPhone/CoreData

Tags:

I have quite a few places in my iPhone application with a line like this:

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();
}

I'm sort of at a loss on what to actually replace abort() with in a production application. I don't suppose there's any simple way to allow users' devices to send the errors back to you. What's the standard practice here?

like image 987
AndrewO Avatar asked Jan 19 '10 21:01

AndrewO


1 Answers

What I've done depends on what is happening in the application. If the save can be rolled back without affecting the application, you can just do that. That would be pretty rare. More likely, you are going to want to let the user know that their save failed. Depending on the cause of the failure, you can offer to try again or explain why it was invalid.

It basically depends on your application and how you would best serve the user.

like image 162
Don Avatar answered Nov 24 '22 05:11

Don