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 Triple-Tap Gesture Recognizer.

Declare a variable and alloc/init it as a gesture recognizer. Then set it to be a triple-tap gesture recognizer.

Sam Soffes

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self];
tap.numberOfTapsRequired = 3;
[self addGestureRecognizer:tap];

the code isn't working. I've checked for spelling issues and syntax, but I don't see any errors.

7 Answers

Amit Bijlani

I must be missing something. This is the last thing I need to complete my iOS Track. What could I be doing wrong?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Your answer above is right but the code challenge is wrong because it is expecting the following:

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
tap.numberOfTapsRequired = 3;

We will have it fixed. Meanwhile, you can use the above code to pass it. Sorry about that!

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(workAlready)];
tap.numberOfTapsRequired = 3;
[self addGestureRecognizer:tap];

I tried that too..

Sam Soffes
STAFF
Sam Soffes
Treehouse Guest Teacher

Can you be more specific than "it's not working"? Also I'm assuming self here is a view and not a view controller.

The code challenge states: "Declare a variable and alloc/init it as a gesture recognizer. Then set it to be a triple-tap gesture recognizer."

I've tried:

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(workAlready)];
tap.numberOfTapsRequired = 3;
[self.view addGestureRecognizer:tap];

also:

[self addGestureRecognizer:tap];

Maybe I'm reading the challenge wrong. Sorry if this isn't very descriptive; I don't know how to explain further.

The challenge: Declare...

What a relief!