相关疑难解决方法(0)

如何立即触发NSTimer?

我需要在应用程序启动时调用方法,然后每隔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秒触发一次?

nstimer ios

42
推荐指数
3
解决办法
1万
查看次数

标签 统计

ios ×1

nstimer ×1