Tuesday, December 3, 2013

Novice problem using @ selector

There is one in the same class as follows:
- (void) hitHere: (NSInteger) number indexPath: (NSString *) str {
NSLog (@ "message printed: number% d, contents% @", number, str);
}

There is this line of code in another method:
UITapGestureRecognizer * singleTouch = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (hitHere: indexPath :)];

In this case @ selector (hitHere: indexPath :) does not pass parameters that way? ? ? ?
That these two parameters that how to pass it? ? ? ? Solving

Reply:
Functions like @ selecttor pass (id) sender parameter, multi-parameter you should then define a method, and then call your - (void) hitHere: (NSInteger) number indexPath: (NSString *) str {

For instance, your method is called - (void) buttonDone: (id) sender
{

[Self hitHere: (NSInteger) number indexPath: (NSString *) str]; assignment parameters on it.
}
I hope to be able to help you.
Reply:
The method can be written

 
- (Void) hitHere: (UIGestureRecognizer *) gesture {
MyCell * cell = (MyCell *) [gesture view];
NSLog (@ "message printed: number% d, contents% @", cell.number, cell.titleContent);
}


Reply:
cited a floor reply:
functions like @ selecttor pass (id) sender parameter, multi-parameter you should then define a method, and then call your - ( void) hitHere: (NSInteger) number indexPath: (NSString *) str {

For instance, your method is called - (void) buttonDone: (id) sender
{

[Self hitHere: (NSInteger) number indexPat ......


Only one parameter is passed, thank you
Reply:
reference to the second floor of the reply:
method can be written

C / C + + code

- (Void) hitHere: (UIGestureRecognizer *) gesture {
MyCell * cell = (MyCell *) [gesture view];
NSLog (@ "message printed: number% d, contents% @", cell.number, cell.titleContent);
}


Do the same way as if you are first down, and there is time to use, thank you
Reply:
references, 4th Floor reply:
reference to the second floor of replies:

The method can be written

C / C + + code

- (Void) hitHere: (UIGestureRecognizer *) gesture {
MyCell * cell = (MyCell *) [gesture view];
NSLog (@ "message printed: number% d, contents% @", cell.number, cell.titleContent);
}


......


This can do it. Ask to see more and more thinking. Oh

No comments:

Post a Comment