Ok, I’ve read the articles about why it’s a better idea to use an NSRunLoop instead of an NSTimer call to run a game loop and maintain a nice frame rate.
But what I haven’t seen in any of the discussions is where to create the NSRunLoop.
Should that be put at the end of didFinishLoading?
The run loop is automatically generated for you when you invoke
NSApplicationMain. You can access the runloop with either of the following methods:The code in the forum you linked to looks like this:
The documentation on
CFRunLoopRunInMode:This means that
CFRunLoopRunInModegets the current threads run loop and processes all waiting inputs. (Like touches…).while(… == kCFRunLoopRunHandledSource)ensures that all events are processed.Just use the code as it is, this is working.