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 8754467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:37:38+00:00 2026-06-13T13:37:38+00:00

I just cant seem to figure out how to update core data object after

  • 0

I just cant seem to figure out how to update core data object after I fetch the object that I want to modify.

This is what I’m trying to do :

1) Find 1st object from core data matching predicate conditions :

NSInteger storeId = 235;  //find object with this id in core data

NSManagedObjectContext *context = [[NSManagedObjectContext alloc] init];
[context setPersistentStoreCoordinator:[self.managedObjectContext persistentStoreCoordinator]];

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Store"
                                          inManagedObjectContext:context];
[request setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"id == %i",storeId];
[request setPredicate:predicate];

NSArray *results = [context executeFetchRequest:request error:NULL];

2) If match found, update matching object (This is where I need help) :

if (results != nil && [results count] > 0)
{
    /** Not sure how to get the correct context and modify object **/

    Store *matchingObject = [results objectAtIndex:0];
    [context setValue:[NSNumber numberWithInteger:storeId] forKey:"id"];
}


/** Save the context */
NSError *error = nil;
if (![context save:&error]) {     
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        //abort();
}

Thank you for any help you can provide…

  • 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-13T13:37:40+00:00Added an answer on June 13, 2026 at 1:37 pm

    Try modifying the object property directly and saving it:

    matchingObject.id = [NSNumber numberWithInteger:storeId];
    

    The object was originally fetched with context so you should be able to save your changes by calling save on context.

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

Sidebar

Related Questions

I'm new to regular expression and just can't seem to figure this out: '/^[A-Za-z0-9](?:.[A-Za-z0-9]+)$/'
I am having a problem that I just can't seem to figure out. The
I'm trying to style Vanilla Forums and I just can't seem to figure out
This should be a simple question, but I just can't seem to figure it
Im sure this is pretty simple but I just cant seem to find the
I know this has been asked before, but I just cant seem to find
This is a super simple question that I just can't seem to find a
i cant seem to figure out how to add the admob widget into my
I've gone back and forth on this problem and can't seem to figure out
Alright, I've been at this for days and can't seem to figure out what

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.