Nsmutabledictionary *Dict= [[Nsmutabledictionary alloc] init];
If (oldview! = Nil)
{
[DictSetobject: oldview forkey: @ "oldview"];
}
If (newview! = Nil)
{
[DictSetobject: newview forkey: @ "newview"];
}
[NstimerScheduledtimerwithtimeinterval: 0.0 target: Self selector: @ selector (Ontimer:)Userinfo:DictRepeats: No];
[Dict release];
-(Void) ontimer :(Nstimer *) Timer
{
Uiview * oldview = [[TimerUserinfo] Objectforkey: @ "oldview"];
Uiview * newview = [[TimerUserinfo] Objectforkey: @ "newview"];
[Uiview animatewithduration: 2.0 delay: 0
Options: uiviewanimationoptionallowuserinteraction
Animations: ^ {
Oldview. Alpha = 0.0;
Newview. Alpha = 1.0;
}
}
As shown in the preceding figure,NstimerIn @ selector (Ontimer:) When passing parameters, the object for passing parameters is stored inNstimerIn the userinfo dictionary, In-(void) ontimer :(Nstimer *) Timer
Use the dictionary.
In fact, this is the general form of passing parameters to the @ selector object on the iPhone.
Go to nstimer to pass the Parameter