1. General situation, use self performselector:sel Withobject:id method
[Self Performselectoronmainthread: @selector (testaa:) withobject:[nsarray arraywithobjects:@ "1" @ "2", nil] waituntildone:no];-(void) Testaa: (nsarray*) data{ if (data==nil| | data.count!=2) { return; } Nsinteger num=[(nsstring*) data[0] intvalue]; Nsinteger index=[data[1] intvalue];}
2, Nstimer: The object that passes the parameter is stored in the Nstimer userinfo dictionary.
Nsmutabledictionary *dict = [[Nsmutabledictionary alloc] init]; [Dict setobject:oldview forkey:@ "Oldview"]; [Nstimer scheduledtimerwithtimeinterval:0.0 target:self selector: @selector (onTimer:) userinfo:dict Repeats:no]; [Dict release];-(void) OnTimer: (Nstimer *) Timer { UIView *oldview = [[Timer userInfo] objectforkey:@ "Oldview"];}
3, UIButton class: By setting tag to use
UIButton * Markbutton=[[uibutton alloc] Initwithframe:cgrectmake (280, 0, 30, 30)]; [email protected] "parameter value"; Here is the parameter value you want to pass [Markbutton addtarget:self action: @selector (Addmark:) forcontrolevents: uicontroleventtouchupinside];-(BOOL) Addmark: (UIButton *) btn { NSLog (@ "%@", Btn.tag];}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The @selector function of iOS passes multiple parameters