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

  • SEARCH
  • Home
  • 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 3429566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:05:51+00:00 2026-05-18T07:05:51+00:00

I have this code sample demonstrating how to update an object in core data,

  • 0

I have this code sample demonstrating how to update an object in core data, however I am having a little issue:

// Retrieve the context
if (managedObjectContext == nil) {
    managedObjectContext = [(YourAppNameAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
}

// Retrieve the entity from the local store -- much like a table in a database
NSEntityDescription *entity = [NSEntityDescription entityForName:@"YourEntityName" inManagedObjectContext:managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entity];

// Set the predicate -- much like a WHERE statement in a SQL database
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"YourIdentifyingObjectProperty == %@", yourIdentifyingQualifier];
[request setPredicate:predicate];

// Set the sorting -- mandatory, even if you're fetching a single record/object
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"yourIdentifyingQualifier" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[request setSortDescriptors:sortDescriptors];
[sortDescriptors release]; sortDescriptors = nil;
[sortDescriptor release]; sortDescriptor = nil;

// Request the data -- NOTE, this assumes only one match, that 
// yourIdentifyingQualifier is unique. It just grabs the first object in the array. 
YourEntityName *thisYourEntityName = [[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0];
[request release];
request = nil;

This line:

YourEntityName *thisYourEntityName = [[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0];

Im not understanding what I should be using in place of ‘YourEntityName’, from what I gathered form who was helping me is that I must use the entity name form the data model, but it doesn’t appear to work, I merely get an undeclared error.

I have an entity named ‘Event’ and that entity has two attributes named userNote and timeStamp.

Im working with this with an essentially brand new clean split view ipad project using core data. I want to run this in a textViewDidEndEditing so when the user has finished typing their note, its updates the object.

  • 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-05-18T07:05:51+00:00Added an answer on May 18, 2026 at 7:05 am

    Replace YourEntityName with the name of the class used to represent your entity. If you have declared a custom class for your entity in Xcode, specify that class here. In your case, it sounds like you haven’t declared a custom class for your entity. In that case, use NSManagedObject as the entity class.

    In Xcode’s data model editor, you can specify both a name and a class for an entity. They are not the same thing. The entity name is used to refer to the entity in statements like this:

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:managedObjectContext];
    

    The entity class specifies the class to use for that entity’s managed objects. When using Core Data, developers often create custom classes to use for their entities, but doing so is not required. If you do want to use a custom class for an entity, you must create that class yourself (as a subclass of NSManagedObject) and specify that class name in the data model editor in Xcode. If you don’t specify a custom class, NSManagedObject is used to represent entity objects.

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

Sidebar

Related Questions

BEGIN dbms_output.put_line('Welcome to PL/SQL'); END; / I have this code in sample.sql file. How
I have this sample code, that works: <video src=./ellen.ogv width=320 height=240 type='video/ogg; codecs=theora, vorbis'
I have this code and I want to keep it elegant. I got stuck
I have a strange problem with absolute positioning and sizing elements to fit around
Thanks in advance for taking the time to read this. Apologies that it is
I'm trying to load JSON back into an object. The loads method seems to
This description is valid for Linux 32 bit: When a Linux program begins, all
What I need to do is capture the result of an expression within an
About a year ago, a question was asked on stackoverflow about how to horizontally
I need to marshal an array of String^ to call a unmanaged function that

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.