Running NSTimer Within an NSThread?

前端 未结 2 911
感动是毒
感动是毒 2021-01-24 05:05

I am trying to run a timer in the background of my application, i am using the timer heavily in my application and i\'d rather running it in the background, However i am getting

相关标签:
2条回答
  • 2021-01-24 05:42

    You're updating your UI in +startTime:, but that method does not run in the main thread. That may be the source of the WebCore warning you're seeing.

    0 讨论(0)
  • 2021-01-24 05:47

    Off the cuff, the NSRunLoop you have in there seems a bit out of place. From the docs:

    In general, your application does not need to either create or explicitly manage NSRunLoop objects. Each NSThread object, including the application’s main thread, has an NSRunLoop object automatically created for it as needed. If you need to access the current thread’s run loop, you do so with the class method currentRunLoop.

    You have a timer, starting a thread, that gets the current run loop and tries to start running it. Do you want to associate the timer with that run loop?

    Via a call to:

    (void)addTimer:(NSTimer *)aTimer forMode:(NSString *)mode

    ?

    0 讨论(0)
提交回复
热议问题