我需要在应用程序启动时调用方法,然后每隔5秒调用相同的方法.
我的代码非常简单:
// Call the method right away
[self updatestuff:nil]
// Set up a timer so the method is called every 5 seconds
timer = [NSTimer scheduledTimerWithTimeInterval: 5
target: self
selector: @selector(updatestuff:)
userInfo: nil
repeats: YES];
Run Code Online (Sandbox Code Playgroud)
是否有计时器的选项,所以它立即触发,然后每5秒触发一次?