Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Anthony Ho
Anthony Ho
10,228 Points

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

Addison Francisco
Addison Francisco
9,561 Points

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]];
Stone Preston
Stone Preston
42,016 Points

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

Anthony Ho
Anthony Ho
10,228 Points
    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]);
        }
    }];
Stone Preston
Stone Preston
42,016 Points

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"];
Anthony Ho
Anthony Ho
10,228 Points

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