iphone - NSTimer doesn't work without UIApplication? -


I have a custom iPhone application which does not rely on UIKit in any way (it is not related to UIKit). This means that I am not using UIApplication and therefore not calling UIApplicationMain . The problem is that when I make a timer, he never fire. Timer has been created like this:

  [NSTimer timerWill time: 10 targets: self selector: @sillector (updatetime) userInfo: zero repeats: TRUE]; I suspect that after the basic initialization has ended in "Menu (Main) " the problem may be related to the loop running, I do this:  
  NSLog (@ "Starting application ..."); ApplicationInstance = [MyApp alloc]; [Application Instant Setmenlayer: Manlyare]; [NSThread detachNewThreadSelector: Targeted by @slector (run app): Object with application: zero]; CFRunLoopRun ();  

I have a reverse-engineer UI Kit and found that there are more things like registration for UIAPCimation system event etc. NSTimer may depend on one of those things. Secondly I have seen that the thread in the representative of UIApplication is similar to the main ().

How do I get NSTimer to work properly? If it is related to run-loop, can anyone point to an error? " CFRunLoopRun () " The main thread is used for hanging so that the remaining applications can run. I do not think that's right.

EDIT: I think the need to configure the run loop. Somehow ...

Your problem is definitely related to the loop; In particular, see the introduction:

Work with timer running loops to effectively use the timer, you should be aware what kind of loops move-see And. Specifically note that while keeping the timer running while loop, you can issue a timer while adding it to the run loop.


Comments