开发者

indexpath as parameters

I got an table which is filled with VM's and i have 2 variable of the datatype NSIndexPath called: selectedindexpath(the row the user clicks on) and selectedindexpathFortheVMtoTurnOn(so it knows which row to reload when the VM went on); which is both made in the .h as @paramters(retain) ..

i got a function that turns on the VM's and a function that CHECKS every 1 sec with a NSTimer if the guest is finally on then it reloads the row of selectedindexpathFortheVMtoTurnOn im doing the same for OFF/REBOOT but i have got a problem with this.. im not able to request an action for more then 1 VM.. because it is overwriting the selectedindexpathFortheVMtoTurnOn value with the last row which i sent an action to and by doing so the table responds wierd and the app crashes.. so thats why i want to give the indexpath.row value as parameters with the NSTimer to the function that checks every 1 sec i have tried a few things but none have worked.. below the code of how i am giving the parameters

timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1
                            target:self
                          selector:@selector(gettheguestyouaskedforTOTURNON:)
                        userInfo:selectedindexpathFortheVMtoTurnOn
                                             repeats:YES];

and the function:

-(void)gettheguestyouaskedforTOTURNON:(NSIndexPath *)therow

and when i try to do a NSLog("%d",therow.row); it crashes...

and with NSLog("%d",therow); i get a whole diffrent value of the selectedindexpathFortheVMtoTurnOn that it used to had..

what am i doing wrong.?

sorry if its a wall of text. but i realy need to fix this problem as this is getting released as BETA nextweek in the appstore for the company where my traineeperiode is.

ty in advance.

EDIT:

i will try to show it with pictures this time. At first im at the view with VM's http://imageshack.us/photo/my-images/194/schermafbeelding2011052l.png/ after that i can press on the button with the arrow and i get to choose what i want to do. http://imageshack.us/photo/my-images/822/schermafbeelding2011052r.png/ an activity indicator appears and it stops when the action is done.(which has to do with the NStimer that checks every 1 sec) http://imageshack.us/photo/my-images/828开发者_StackOverflow社区/schermafbeelding2011052y.png/ http://imageshack.us/photo/my-images/811/schermafbeelding2011052t.png/ but when i try to do an action at 2 or more VM's the activity indicator on the last row i selected spins *x faster(depends on how manny actions i send.. 2 actions means it spins 2 times faster..(so weird)

.. i hope this is enough for you to understand what i mean now =)


The method triggered by an NSTimer object always has the timer as the argument. You can get the row like this.

-(void)gettheguestyouaskedforTOTURNON:(NSTimer *)timer {
    NSIndexPath *indexPath = (NSIndexPath*)[timer userInfo];

    NSLog(@"%d", indexPath.row);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜