How to make a function been called every frame in the cocoa programming?
I know cocoa application has a main run loop, how to make a function been called every frame? I mean this function sh开发者_开发问答ould be called every process of the main loop. Is that through the -(void) run of the + (NSRunLoop*) currentRunLoop;?
You can call getCFRunLoop to get the Core Foundation RunLoop. Then it's just a matter of adding an observer to the CFRunLoop. See the docs for this function:
CFRunLoopAddObserver()
I'm assuming you are targeting OSX since the tag is cocoa and not cocoa-touch so if you want to synchronize with every screen frame update you should check out CVDisplayLink
I know it's been quite some time. Anyway this might come useful for someone who stumbled upon here like me.
精彩评论