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 Photo Browser iPhone App Gestures Introducing Gesture Recognizers

Nic Huang
PLUS
Nic Huang
Courses Plus Student 10,573 Points

Like specific photo

When we like a photo, we log photo's link and use its id as parameter to send request. But what I don't understand here is that how we can get specific photo's id and link by simply attaching a tap gesture on it. There is no "didSelect..." delegate method implemented, and we don't send any parameter in gesture's selector. How do we make certain the link and the parameter is the one I tapped??

1 Answer

Sam Soffes
STAFF
Sam Soffes
Treehouse Guest Teacher

We know which photo was double tapped since we add the gesture recognizer to the collection view cell. The cell already has a photo, so when there is a double tap in the cell, we know it's the photo that belongs to that cell.

Gesture recognizers use target-action instead of a didSelect delegate. That's why the like method gets called in the cell when you double tap.