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 Adding Friends by Tapping on a Table View Cell

Adding Friends By Tapping On A Table View Cell (Challenge)

I'm stuck on this challenge and can't quite figure out how to get the code running without errors. I feel it's correct... but clearly there's an issue and I can't quite put my finger on it.

Objective: We are working on an app to download videos of the Treehouse Show, which are listed in a table view. The user will tap on items in the list to create a list of shows to download. For each tap, add code below to simply mark rows as selected or not using 'UITableViewCellAccessoryCheckmark' and 'UITableViewCellAccessoryNone'.

My Code: // This code is excerpted from the didSelectRowAtIndexPath method of a view controller

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

// Add your code below to mark rows as selected or not! if (cell.accessoryType == UITableViewCellAccessoryNone) { cell.accessoryType == UITableViewCellAccessoryCheckmark; } else { cell.accessoryType == UITableViewCellAccessoryNone; }

2 Answers

Stone Preston
Stone Preston
42,016 Points

you used == when you should have used = to assign the cell the new accessoryType

if (cell.accessoryType ==  UITableViewCellAccessoryNone) { 
    //only use 1 equal sign to assign 
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
 } else { 
    // only use 1 equal sign to assign
    cell.accessoryType = UITableViewCellAccessoryNone;
 }

Perfect, thanks! Tired eyes make for careless mistakes...