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 Relating Users in Parse.com Removing Friends by Tapping on a Table View Cell

Pablo Alfaro
PLUS
Pablo Alfaro
Courses Plus Student 6,923 Points

*Extra credit* Displaying friend information

I'm trying to complete the extra credit assignment but I'm stuck when displaying a friend's information. This is my code on FriendsTableViewController.m I would like to know what am I missing or doing wrong when passing the friends data to the FriendsDetailViewController

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

    FriendDetailViewController *fvc = [[FriendDetailViewController alloc]init];
    fvc.friends = [NSMutableArray arrayWithArray:self.friends];
    PFUser *user = [self.friends objectAtIndex:indexPath.row];
        fvc.nameLabel.text = user.username;
    NSLog(@"%@",user.username);//displays username
    NSLog(@"%@",fvc.nameLabel.text);//displays null

//This is my code in FriendDetailViewController.m

  • (void)viewDidLoad { [super viewDidLoad]; if (self.user) { self.nameLabel.text = self.user.username; }else{ self.nameLabel.text = @"No data to display"; } } //displays "No data to display" ```

1 Answer

Pablo, here is a full template for the social network application with all of this functionality built-in: Click Here.