timer - Objective c: passing an NSTimer with a button -
how pass nstimer have declared timer down method being called button?
[stickfig addtarget:self action:@selector(tapfig:andtime:) forcontrolevents:uicontroleventtouchupinside];
sorry formatting. had ask on phone.
you can not action: send button itself. inside class may want store values inside of nsdictionary. can tag buttons , use tags nsnumber key of dictionary.
ex.
... //tag buttons button1.tag = 1; button2.tag = 2; button3.tag = 3; //add timers dictionary [mutabledictionary setobject:button1timer forkey:[nsnumber numberwithint:button1.tag]]; ... //action buttons -(void)tapfig:(id)sender { nstimer *timer = [mutabledictionary objectforkey:[nsnumber numberwithint:((uibutton*)sender).tag]]; }
Comments
Post a Comment