将间隔从5秒更改为特定时间

时间:2010-11-10 23:49:32

标签: iphone objective-c cocoa-touch nstimer

timer =[NSTimer scheduledTimerWithTimeInterval:5.0 
                                        target:self 
                                      selector:@selector(onTimer) 
                                      userInfo:nil 
                                       repeats:YES];

我可以将scheduledTimerWithTimeInterval更改为当天的特定时间吗?没有改变我已经拥有的很多代码?

1 个答案:

答案 0 :(得分:3)

文档是你的朋友:

timer = [[[NSTimer alloc] initWithFireDate:myDate interval:5.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES] autorelease];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];