1

I have the object GroupRequest and Group on Parse.com. Each GroupRequest has a pointer to a Group object called "group". I have queried to obtain an array of GroupRequests, and now I am trying to display the "name" string property of each Group in the GroupRequests in that array on a table view.

However, I am running into trouble when I try to access [@"name"]. The program crashes and says:

"'NSInternalInconsistencyException', reason: 'Key "name" has no data. Call fetchIfNeeded before getting its value.'"

How can I access the group names properly? Below is the code I'm using to try to access the [@"name"] property:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath];

self.pendingRequestBeingDisplayed = [self.pendingRequests objectAtIndex:indexPath.row];

self.tempGroup = self.pendingRequestBeingDisplayed[@"group"];

cell.textLabel.text = self.tempGroup[@"name"];


return cell;

}

self.pendingRequests is the array of GroupRequest Objects.

2 Answers 2

1

you need to get pointer fields by writing

[query includeKey:@"group"];

Sign up to request clarification or add additional context in comments.

4 Comments

wait so if I query to get the grouprequests, would I then have to query again to get the users in "to" and then query again to get the "group" PFObject I want?
what i'm saying is...is there anyway to access PFObjects using the pointer? I don't want to have to use a query every time.
No, you don't have to query every time for nested objects if you include the sub-object key.
If you have only the pointer then you always have to query to get the corresponding object. Hope that helps.
0

When you run a query, by default you get the pointer fields as pointers, not as PFObjects. If you want to get the pointer fields as PFObjects, you have to call

[query includeKey: @"the_name_of_the_pointer_column"];

before you execute the query.

2 Comments

wait so if I query to get the grouprequests, would I then have to query again to get the users in "to" and then query again to get the "group" PFObject I want?
No, if you use includeKey, then it is just one query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.