Note that there are some explanatory texts on larger screens.

plurals
  1. POCore data multiple managedObjectContexts
    primarykey
    data
    text
    <p>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. </p> <p>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. </p> <pre><code>- (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]]; } [...] } </code></pre> <p>At this point: <code>aPerson = (id)[self.editingContext objectWithID:[aPerson objectID]];</code> when I print the description in the debugger for aPerson I should get</p> <pre><code>&lt;AWPerson: 0x6b5de70&gt; (entity: Person; id: 0x6b5bb60 &lt;x-coredata://A6EC85F2-81A8-488F-B2E3-F82687C252A2/Person/p1&gt; ; data: { dateOfBirth = "1973-11-03 12:53:58 +0000"; eyeColor = "(...not nil..)"; firstName = Peter; lastName = Dickens; yearOfBirth = 1973; </code></pre> <p>instead I get the following where <code>&lt;fault&gt;</code> has replaced the values</p> <pre><code>&lt;AWPerson: 0x6b609d0&gt; (entity: Person; id: 0x6b5bb60 &lt;x-coredata: //A6EC85F2-81A8-488F-B2E3-F82687C252A2/Person/p1&gt; ; data: &lt;fault&gt;) </code></pre> <p>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.</p> <p>Thanks, Steve </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload