定期调用ios中的Web服务

时间:2013-10-07 01:02:07

标签: ios objective-c nstimer

我有NSTimer这样:

[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秒就调用一次网络服务:

示例:第一次通话在45秒内,第二次在90秒内等等。

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

1 个答案:

答案 0 :(得分:0)

您只需修改NSTimer 45秒:

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