Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently working on moving some Android-ndk code to the iPhone.

From looking at some samples it seems that the main loop is handled for you and all you've got to do is override the render method on the view to handle the rendering. Then add a selector to handle the update methods. The render method itself looks like it's attached to the windows refresh.

But in android I've got my own game loop that controls the rendering and updates using C++ time.h. Is it possible to implement the same here bypassing Apple's loop? I'd really like the keep the structures of the code similar.

share|improve this question
up vote 1 down vote accepted

Short answer is no, although you are allowed to use pthreads for all your dirty work I discourage you from doing it just because of multithreading issues that can occur.

Unfortunately all mobile platforms have constraints related to the fact that all the things must be correctly paused and resumed in any moment so it's better to rely on GCD of iOS without wanting to go too much beyond edges (I personally had big troubles with similar issues).

In any case I don't see why you should have to change so much code, you should be able to encapsulate your update functions easily so that your custom scheduler manages them in Android while on iOS you let the OS call them through callbacks. You shouldn't need to change almost anything.

share|improve this answer
Hi Jack, yes the changes I'll have to make aren't exactly big, but I was hoping to keep the code as similar as possible. But if it's going to be that much more complex, then I think it's better to use the structure provided and modify my code to work on both. thanks! – kkan Apr 2 '12 at 6:07

I don't have any serious iOS experience, but this article looks like it might be useful to you. It's basic around using CADisplayLink's ability to help you synchronize your code with the screen's refresh rate.

Like Jack said, the answer seems to be no. Write the system once for both systems and recycle it.

share|improve this answer
Thanks for the link! I'm going to modify the code so that it can sit in a happy place for both. – kkan Apr 2 '12 at 6:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.