title: iOS: CoreData Exception when updating data
body: <p>I am trying to update an existing record in a database using CoreData, but I am getting an exception when using the Managed Object accessor method.  </p>
  
  <p>Code excerpt:          </p>
  
  <pre><code>NSManagedObjectContext *tmpManagedObjectContext = [self.fetchedResultsController managedObjectContext];
  
  NSFetchRequest *request = [[NSFetchRequest alloc] init];
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"Contact" inManagedObjectContext:tmpManagedObjectContext];
  [request setEntity:entity];
  
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"contact_id = %@", [dict objectForKey:@"contact_id"]];
  [request setPredicate:predicate];
  
  NSError *error = nil;
  [request setResultType:NSDictionaryResultType];
  [request setPropertiesToFetch:[NSArray arrayWithObjects:@"first_name",@"sync_status",nil]];
  
  Contact *contact = [[managedObjectContext executeFetchRequest:request error:&amp;error] objectAtIndex:0];
  contact.sync_status = @"Y";
  
  error = nil;
  if (![tmpManagedObjectContext save:&amp;error]) {
      NSLog(@"Error setting sync status on contact record - error: %@", [error localizedDescription]);
  }
  </code></pre>
  
  <p>The line that is causing the error is:</p>
  
  <pre><code>contact.sync_status = @"Y";
  </code></pre>
  
  <p>Error is <strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSKnownKeysDictionary1 setSync_status:]: unrecognized selector sent to instance 0x8907fd0'
  *</strong> First throw call stack:</p>
  
  <p>Contact is a NSManagedObject class which I automatically generated in Xcode.</p>
  
  <p>Is my approach incorrect here? I haven't had any problems with retrieving or deleting records, but I am stumbling on how to update data.</p>
  
  <p>Any guidance or help would be greatly appreciated. Thanks.</p>