title: core data error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't do regex matching on object 0
body: <p>I'm creating a core data favorite feature. I have a favorite attribute with type boolean in recipe table. There are 2 views. </p>
  
  <p>First view is for user to select favorite.
  Second view display a list of favorites that is selected. </p>
  
  <p>The feature works fine when i go to the  first view. However, the app crashed after i go to the second view and go back to first view again. I get the following error:  </p>
  
  <p><pre><code>    2012-01-09 18:44:09.455 coredata[1354:12503] CoreData: error: Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  Can't do regex matching on object 0. with userInfo (null)
      2012-01-09 18:44:09.457 coredata[1354:12503] <em>*</em> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't do regex matching on object 0.'</p>
  
  <p></pre></code></p>
  
  <p>My code for the method in first view that toggle the favorite attribute to 1 or 0: </p>
  
  <p><pre><code>
      - (IBAction)favoriteButtonPressed:(id)sender {</p>
  
  <pre><code> if (recipe.favorite == 0) {
  
   [favoriteButton setSelected:YES];
   favoriteButtonSelected = 1;
   [favoriteButtonImage setImage:[UIImage imageNamed:@"selected.png"] forState:UIControlStateNormal];
  
       self.recipe.favorite = [NSNumber numberWithInteger:1];
  
   }else {
  
   [favoriteButton setSelected:NO];
   favoriteButtonSelected = 0;
   [favoriteButtonImage setImage:[UIImage imageNamed:@"unselected.png"] forState:UIControlStateNormal];
  
       self.recipe.favorite = [NSNumber numberWithInteger:0];
  
   }
      NSManagedObjectContext *context = recipe.managedObjectContext;
      NSError *error;
   if (![context save:&amp;error]) {
    NSLog(@"Tried to save favorite Unresolved error %@, %@", error, [error userInfo]);abort();
       }
  } 
  </code></pre>
  
  <p></pre></code></p>
  
  <p><strong>Updated:</strong>
  Is it a problem that i did not update the database? I have searched around and found the following method, where should i include this into the code? </p>
  
  <p><pre><code>[context refreshObject:recipe mergeChanges:NO]; </pre></code></p>
  
  <p>Can anyone help please? Thanks!</p>