Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7711351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:21:12+00:00 2026-06-01T01:21:12+00:00

I am trying to update an existing record in a database using CoreData, but

  • 0

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.

Code excerpt:

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:&error] objectAtIndex:0];
contact.sync_status = @"Y";

error = nil;
if (![tmpManagedObjectContext save:&error]) {
    NSLog(@"Error setting sync status on contact record - error: %@", [error localizedDescription]);
}

The line that is causing the error is:

contact.sync_status = @"Y";

Error is * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[NSKnownKeysDictionary1 setSync_status:]: unrecognized selector sent to instance 0x8907fd0’
*
First throw call stack:

Contact is a NSManagedObject class which I automatically generated in Xcode.

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.

Any guidance or help would be greatly appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:21:13+00:00Added an answer on June 1, 2026 at 1:21 am

    You’ve configured your fetch request to return dictionaries instead of managed objects. If you want to update the returned objects, you must ask for them in the fetch request – that is, use the default behaviour instead of what you are doing.

    Remove these lines:

    [request setResultType:NSDictionaryResultType];
    [request setPropertiesToFetch:[NSArray arrayWithObjects:@"first_name",@"sync_status",nil]];
    

    And you’ll be fine. The lines above are used if you only want to return certain properties in the fetch, but you want the whole object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to update an object in my MS SQL 2005 database using
I'm trying to update an existing C# code. The code is parsed using ICSharpCode.NRefactory.IParser
I am not a .Net guy but trying to get update an existing .net
I'm trying to update a hashtable in a loop but getting an error: System.InvalidOperationException:
I am trying to update files inside an existing WAR file using the ANT
I am trying to insert a record. This code worked but has stopped working
I'm trying to do the classic Insert/Update scenario where I need to update existing
I trying to update a model on a callback but the validation is causing
I need help with trying to insert a record using MVC and Entity Framework.
I am trying to create a nested form using formtastic. I've included my code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.