I am making an app that has a king of “update method” that is responsible for running code continually. I thought of using an NSTimer as it has an option to have it repeat indefinitely. I have it load as such:
gameTimer = [NSTimer timerWithTimeInterval:0.01428 target:self selector:@selector(GameUpdate:) userInfo:NULL repeats:true];
Where the GameUpdate: declaration is like so:
-(void)GameUpdate:(NSTimer*)timer;
The thing is, the code inside GameUpdate: never runs. It used to work in xcode 4.2. Why is this?
You need to add your newly created NSTimer object to the run loop.
(lifted from the answer to this related question): As the docs say:
If you look at the other answers to that related question, you’ll see how to create a NSTimer object where it gets automatically added to the run loop.