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

tableview dont update with retrieved messages

hi guys,

here another issue, i ve implemented retrieving data from parse.com , ive still an issue whereby i cant share pictures while sharing a video is not a problem (see my another discussion)...

when i share a video, i see at the back end Parse that it is saved. when i want to retrieve, i see in the nslog that the retrieved messages are 3 (this is right).

when I run the app, i dont see anything in the inbox, which means that tableview dont update/show retrieved messages.

here is my inboxvc.m:

//  InboxTableViewController.m
//  Ribbit
//
//  Created by BLANCO on 15-04-14.
//  Copyright (c) 2014 KIWS. All rights reserved.
//

#import "InboxTableViewController.h"
#import <Parse/Parse.h>

@interface InboxTableViewController ()

@end

@implementation InboxTableViewController



- (void)viewDidLoad
{
    [super viewDidLoad];

    PFUser *currentUser = [PFUser currentUser];
    if (currentUser) {
        NSLog(@"Current user: %@", currentUser.username);
    }

    else {

    [self performSegueWithIdentifier:@"showLogin" sender:self];
    };

}


-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    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]);
        }
    }];
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    // Return the number of rows in the section.
    return [self.messages count];
}


#pragma mark - Table view



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


    PFObject *message = [self.messages objectAtIndex:indexPath.row];
    cell.textLabel.text = [message objectForKey:@"senderNamer"];

    return cell;
}


#pragma mark - Table view delegate

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}




#pragma mark - Helper methods
- (IBAction)logout:(id)sender {

    [PFUser logOut];
    [self performSegueWithIdentifier:@"showLogin"  sender:sender];
}



@end```

''''
here header file. i think here is some issue, there is no tableView,

```//
//  InboxTableViewController.h
//  Ribbit
//
//  Created by BLANCO on 15-04-14.
//  Copyright (c) 2014 KIWS. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface InboxTableViewController : UITableViewController

@property (nonatomic, strong) NSArray *messages;

- (IBAction)logout:(id)sender;

@end```

4 Answers

I made a typo in

"cell.textLabel.text = [message objectForKey:@"senderNameR"];

senderNameR => senderName

Luke Terzich
Luke Terzich
5,193 Points

Oops analysed all your code and found the problem scrolled down to comment and realised you'd fixed it! hahah awkward! Glad its all working pal

haha sorry man...I DO appreciate like you solved my problem!

Luke Terzich
Luke Terzich
5,193 Points

Thats okay haha maybe get their in time next time ;)