For ios, the question about passing parameters in the selector event seems simple but confusing (resolved). iosselector
Recently, when using selector,
Add a click event to UIButton. You can add ":" After selector to pass the button as a parameter to the method,
Use today
[NSTimerscheduledTimerWithTimeInterval: 1 target: selfselector: @ selector (rotateAction :) userInfo: nilrepeats: NO];
Write a method
# Pragma mark-rotateAction
-(Void) rotateAction :( ViewController *) controller {
// UIView * view = [controller. view. subviews lastObject];
NSLog (@ "% @", controller );
// View. backgroundColor = [UIColor yellowColor];
}
Similar Writing seems to be unable to obtain self (controller). I printed the self and controller results and found that the address is different, so it is definitely not an object. I am thinking about why, check the printed results and find out the problem.
15:35:22. 806 testAffine Transformation[10698: 1998925] <ViewController: 0x7ff64db38a50>
15:35:23. 807 testAffine Transformation[10698: 1998925] <__nscftimer: 0x7ff64d8486d0>
Obviously they are not the same class, so the parameters passed by selector are: Click Event callers such as button, slider, progress, nstimer, etc.