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

Stuck on "Adding Friends By Tapping On a Table View Cell" code challenge.

Hey guys,

So I've been sitting and looking at my screen scratching my head and I'm completely lost for the answer and wondering if anyone has any advice for how I can get it right.

The code challenge asks...

"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'."

I'll keep working to get an answer.

Thanks

Stu :)

1 Answer

So I finally I got it and in my research in the forum I came across this and I'll quote Andres Mauricio Guerrero

**well, I´m going to try to help you by giving as little to no code as possible, you have this "if" condition:

if (cell.accessoryType == UITableViewCellAccessoryNone) { } else { }

first know what´s being asked, then understand your if condition, if for each tap you want to mark your row as checked or unchecked then you could see that your'e doing opposite tasks here, so knowing that, the you go to the "if" condition.

this condition what is telling us in our human language is "if the cell that we touched has nothing on it (in this case unchecked), then do... else, do the opposite thing" so what do we want to do if the cell is unchecked? and what do we want to do if the cell is checked (else statement)? hope this helps you, let me know ;)**

This pretty much helped me to get the correct answer!