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 trialDustin James
11,364 PointsDeclare a variable and alloc/init it as a gesture recognizer. Then set it to be a triple-tap gesture recognizer.
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
Dustin James
11,364 PointsI must be missing something. This is the last thing I need to complete my iOS Track. What could I be doing wrong?
Sam Soffes
Treehouse Guest TeacherYou want initWithTarget:action:
Dustin James
11,364 PointsUITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(workAlready)];
tap.numberOfTapsRequired = 3;
[self addGestureRecognizer:tap];
I tried that too..
Sam Soffes
Treehouse Guest TeacherCan you be more specific than "it's not working"? Also I'm assuming self
here is a view and not a view controller.
Dustin James
11,364 PointsThe 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.
Dustin James
11,364 PointsThe challenge: Declare...
Dustin James
11,364 PointsWhat a relief!
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherYour answer above is right but the code challenge is wrong because it is expecting the following:
We will have it fixed. Meanwhile, you can use the above code to pass it. Sorry about that!