Note that there are some explanatory texts on larger screens.

plurals
  1. POPFUser throwing NSInternalInconsistencyException when calling objectForKey after fetchAllIfNeeded
    primarykey
    data
    text
    <p>I have two additional columns on my PFUser "firstName" and "lastName". They are saving properly; I can see the data in the data browser.</p> <p>I have another PFObject "class" that has a property with a NSArray of PFUsers. I use the class method <strong>+fetchAllIfNeededInBackground:block:</strong> on PFObject to fetch the array of PFUsers. In the callback block, I call objectForKey: on each of the PFUsers in the array, but I access them through the owning PFObject.</p> <pre><code>// invited is the NSArray of PFUsers self.whoCell.mainLabel.text = [[self.plan.invited objectAtIndex:0] objectForKey:@"firstName"]; </code></pre> <p>Debugger outputs this at a breakpoint right before the objectForKey call:</p> <pre><code>(lldb) po self.plan.invited (NSArray *) $4 = 0x06e62a60 &lt;__NSArrayM 0x6e62a60&gt;( &lt;PFUser:GCCdPjCU2J&gt; { firstName = Fake; lastName = Account; username = yyajnbafv53qw4yhjm9sfoiis; } ) </code></pre> <p><strong>Edit:</strong> adding implementation of self.plan.invited because the above is misleading.</p> <pre><code>- (NSArray*)invited { // self.dataSource is a PFObject* return [self.dataSource objectForKey:INVITED_PROP]; } </code></pre> <p>Yet when the above call it made to <strong>objectForKey:</strong> this exception is thrown:</p> <pre><code>'NSInternalInconsistencyException', reason: 'Key "firstName" has no data. Call fetchIfNeeded before getting its value.' </code></pre> <p><strong>Edit:</strong> Accessing the array of fetchedObjects that is passed to the block callback for <strong>+fetchAllIfNeededInBackground</strong> doesn't throw, but accessing the actual array that was originally passed to <strong>+fetchAllIfNeededInBackground</strong> throws.</p> <p>Calling fetchIfNeeded before the call solves the problem, but why? The data is already there. Do I miss understand <strong>+fetchAllIfNeededInBackground</strong> in that it DOES NOT updated the PFObject that owns to collection of PFUsers?</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