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

Trouble with adding profile (Extra credit for Relating Users in Parse.com)

When I tap the cell nothing happens. If I pass an NSLog of the selectedUserId it logs it just fine.

So far here is the code that I have: ProfileViewController.h

#import <UIKit/UIKit.h>

@interface ProfileViewController : UIViewController
@property (strong, nonatomic) NSString *userId;

@end

FriendsViewController.h

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface FriendsViewController : UITableViewController

@property(strong, nonatomic) PFRelation *friendsRelation;
@property(strong, nonatomic) NSArray *friends;
@property (strong, nonatomic) NSString *selectedUserId;

@end

FriendsViewController.m (Only the two added bits of code)

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {    
    //added for profile
    if ([segue.identifier isEqualToString:@"showProfileView"]) {
        ProfileViewController *pvController = (ProfileViewController *)segue.destinationViewController;
        pvController.userId = self.selectedUserId;
    }
}

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

    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
    //get user of current index path
    PFUser *user = [self.friends objectAtIndex:indexPath.row];

    //get the object ID of the user and assign it to selected user ID
    self.selectedUserId = user.objectId;
}

Here is a screenshot of my storyboard set up for the two view controllers: https://www.dropbox.com/s/8a5a4iilc65dfpa/Screen%20Shot%202014-06-29%20at%206.03.06%20PM.png

Here is a screen shot of the identifier for the segue: https://www.dropbox.com/s/rtdwu23xmo98yvi/Screen%20Shot%202014-06-29%20at%206.03.26%20PM.png

Is there something that I am missing?

1 Answer

I have fixed it. If you look at the screen shot of the storyboard you'll see that the segue is coming from the edit friends view control and not the friends list view controller. Thank goodness. That's a few hours of my life that I'll never get back! I hope this issue helps somebody else down the road.