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

Self-destructing Message iPhone App

In the video, "Adding Friends by Tapping on a Table View Cell," in Stage 3 of the project, Ben's implementation file for View Controllers has the method "didSelectRowAtIndexPath." For some reason, on Xcode 5, this method is not present at the bottom of the file. I delete all the commented out code, just as Ben says.

Thanks for any help in advance.

1 Answer

Hi Jeremy!

didSelectRowAtIndexPath is a delegate method for UITableView. Delegates can be used to intercept events, and you can read up more about the UITableViewDelegate on Apple's documentation. Your table view already conforms to the UITableViewDelegate protocol, so you can add the method as you would any other one (and autocomplete will complete this for you):

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Add some code here for when user taps on a cell row!
}

For some reason, Xcode 5 no longer includes this method in the implementation file by default when creating a new subclass of UITableViewController as we're doing in the Ribbit project. However, adding it in works as expected. Hit this small snag when going through the project, too :)