Mahir
Mahir

Reputation: 1684

Is it possible to send objects with UITapGestureRecognizer initWithTarget:action:

I currently have this in my code

tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(updateLeftLabel:)];

which calls

- (void)updateLeftLabel:(UIGestureRecognizer*)recognizer 

My code would be cleaner if the method was

- (void)updateLeftLabel:(UIGestureRecognizer*)recognizer fromData:(EquationData*)data

However, I need a way to send the 'data' parameter when I init UITapGestureRecognizer

Upvotes: 0

Views: 1072

Answers (2)

infiniteLoop
infiniteLoop

Reputation: 2183

Why Complicate ??? Subclass UITapGestureOrganiser and use any number of custom objects in the new class.

Upvotes: 4

Costique
Costique

Reputation: 23722

You can use associated objects to attach data to the gesture recognizer.

Upvotes: 0

Related Questions