How can I run code block in background periodically using GCD?
问题 How can I run code block in background periodically using GCD? I am trying to write a game engine with several subsystems, like rendering, physics, game logic and so on. Some tasks should be event-driven, but some (like physics system) should be called periodically in the background with constant time (for example after 1/100 sec). I created a block of code, but how can I run this block periodically in background? Is GCD right tool here? 回答1: What you want is a GCD dispatch source. For sample