开发者

How to make a function been called every frame in the cocoa programming?

开发者 https://www.devze.com 2023-02-04 06:30 出处:网络
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 -

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消