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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:59:56+00:00 2026-06-04T21:59:56+00:00

Update: note that the actual problem here wasn’t with core data more with a

  • 0

Update: note that the actual problem here wasn’t with core data more with a bad property declaration of mine – strong/weak – that resulted in the object being released between viewWillLoad and viewDidLoad of the new view.

I’m working through Tim Isted’s book on Core Data in iOS and have been doing fine up until now. I’m trying to follow how the new viewController uses a second managedObjectContext – editingContext in the below – to capture changes in the text fields before saving.

- (void)setCurrentPerson:(AWPerson *)aPerson {
    if( !aPerson )
    {
        aPerson = [AWPerson randomPersonInManagedObjectContext:self.editingContext];
    }
    else if( [aPerson managedObjectContext] != self.editingContext ) {
        self.title = @"Edit person";
        aPerson = (id)[self.editingContext objectWithID:[aPerson objectID]];
    }
    [...]
}

At this point:
aPerson = (id)[self.editingContext objectWithID:[aPerson objectID]];
when I print the description in the debugger for aPerson I should get

<AWPerson: 0x6b5de70> (entity: Person; id: 0x6b5bb60 <x-coredata://A6EC85F2-81A8-488F-B2E3-F82687C252A2/Person/p1> ; data: {
    dateOfBirth = "1973-11-03 12:53:58 +0000";
    eyeColor = "(...not nil..)";
    firstName = Peter;
    lastName = Dickens;
    yearOfBirth = 1973;

instead I get the following where <fault> has replaced the values

<AWPerson: 0x6b609d0> (entity: Person; id: 0x6b5bb60 <x-coredata:
//A6EC85F2-81A8-488F-B2E3-F82687C252A2/Person/p1> ; data: <fault>)

I really can’t see what’s happening. Before the line aPerson has the values, after the line, they are replaced. Any help would be greatly appreciated.

Thanks, Steve

  • 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-04T21:59:58+00:00Added an answer on June 4, 2026 at 9:59 pm

    I do not have that book, but I’ll try to help…

    However, it does not look wrong to me. It looks like exactly what I would expect (assuming aPerson lives in a different context when setCurrentPerson is called). I’ll try to walk through the code you posted. Maybe I can some how determine what your question is, and somehow provide an answer in the process. My comments are included in the code as, well, comments.

    - (void)setCurrentPerson:(AWPerson *)aPerson {
        if( !aPerson )
        {
            // The aPerson object we were given is nil, so get one in the
            // current editingContext.
            aPerson = [AWPerson randomPersonInManagedObjectContext:self.editingContext];
        }
        else if( [aPerson managedObjectContext] != self.editingContext ) {
            // The aPerson object does not live in editingContext.  However, apparently
            // we want to make sure it lives in the editingContext.  Remember, each managed
            // that has been saved will have a permanent object-id.  Any context can use
            // the object-id to fetch an object into its own ManagedObjectContext.
            self.title = @"Edit person";
            aPerson = (id)[self.editingContext objectWithID:[aPerson objectID]];
    
            // Now, aPerson will point to an object that lives in the MOC editingContext.
            // However, if it was not previously registered in that MOC, it will be returned
            // as a fault.  This does not mean the object is not there, but this MOC has
            // not loaded its data.  As soon as you cal a method that needs the data,
            // it will be faulted into memory.
    
            // One way, is to access any of its properties.
            NSLog(@"firstName = %@", [aPerson valueForKey:@"firstName"]);
    
            // You can query an object to see if it is a fault.  NO means it's
            // not a fault, and the properties should all be in memory.  YES, does not mean
            // the data is NOT in memory though... it could be in a cache...
    
            // You can manually fault the object into memory, but I would
            // suggest you read all the documentation before using this, because it has
            // side effects.  Consider...
            if ([aPerson isFault]) {
                [self.editingContext refreshObject:aPerson mergeChanges:YES];
            }
    
            // NOTE: In general, you just want the object management system itself
            // to manage faults.  However, if you really want to see that your objects
            // are what they are supposed to be, you can do any of this to examine them.
        }
        [...]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code (note the code below doesnt update the property) private
Update: The index.php file here: /public_html/d/index.php includes: /public_html/d/core/source/class.File1.php This Class.File1.php here has this include
NOTE: This question changed a little as I learned more about the problem, so
NOTE: I added my new solution at the UPDATE answer below. I try to
Update: I was able to solve this problem. I just remembered VBA use *
UPDATE: I found that the easiest way is to use AQuery . I need
So i bet i got you curious with that title. =) Here's the scenario
Before I get to my question/problem, here is the basic structure of my application:
I have a problem with time measuring that's really bothering me. I am executing
Edit : Moved the actual question to the top. Update : Found an example

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.