Keep an NSThread containing an NSTimer around indefinitely? (iPhone)

六月ゝ 毕业季﹏ 提交于 2019-12-03 21:43:50

You're close. All you need to do now is start the run loop running so the thread doesn't exit and the timer runs. After your call to initWithTimerInterval:, just call

[[NSRunLoop currentRunLoop] run];

The thread will run its run loop indefinitely and your timer will work.

It sounds like you might want an NSOperation instead of an old fashion thread. You could active the operation via a universal timer then it would execute on its own thread and then clean up its own memory when done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!