Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Self-Destructing Message iPhone App Retrieving and Viewing Data from Parse.com Retrieving Data from Parse.com

Cannot retrieve messages from Parse

When I use ```self.messages = objects; [self.tableView reloadData]; NSLog (@"Retrieved %d messages", [self.messages count]);

,the console shows 0 messages.

3 Answers

I had the same issue. Looking at my parse tables, I realized that something was different than in the video.

[query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]];

in parse the column for recipients is actually called recipientsIds. So change that line of code to this

[query whereKey:@"recipientsIds" equalTo:[[PFUser currentUser] objectId]];

can you post the code you are using in your query?

    PFQuery *query = [PFQuery queryWithClassName:@"Messages"];
    [query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]];
    [query orderByDescending:@"createdAt"];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if(error){
            NSLog(@"Error %@ %@", error, [error userInfo]);
        } else{
            //we found messages
            self.messages = objects;
            [self.tableView reloadData];
            NSLog (@"Retrieved %d messages", [self.messages count]);
        }
    }];

ok looking at this line here:

PFQuery *query = [PFQuery queryWithClassName:@"Messages"];

double check your parse backend using the parse data viewer and make sure you named your class "Messages". you may have called it "Message". if you did name it Message thats whats causing the issue and you would need to change that in your code to

PFQuery *query = [PFQuery queryWithClassName:@"Message"];

The the class name in Parse.com is "Messages" . I named this originally