2013-10-07 56 views
0

我有一个NSTimer这样的:定期调用Web服务在IOS

[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(sliderUpdate:) userInfo:nil repeats:YES]; 

-(void)sliderUpdate:(id)sender 
{ 
    int currentTime = (int)((newPlayer.currentTime.value)/newPlayer.currentTime.timescale); 
    slider.value=currentTime; 
    NSLog(@"%i",currentTime); 
    song.currentTime=currentTime; 
    int currentPoint=(int)((newPlayer.currentTime.value)/newPlayer.currentTime.timescale); 
    int pointMins=(int)(currentPoint/60); 
    int pointSec=(int)(currentPoint%60); 
    NSString *strMinlabel=[NSString stringWithFormat:@"%02d:%02d",pointMins,pointSec]; 
    lblSlidermin.text=strMinlabel; 
    song.strslidermin=strMinlabel; 
} 

我想要做的,是在每45秒内每次,并调用Web服务:

例:45秒内第一次呼叫,90秒内第二次呼叫等。

我该如何在此NSTimer中执行此操作?

回答

0

你只需要修改你的NSTimer 45秒:

[NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(sliderUpdate:) userInfo:nil repeats:YES];