NSTimer and NSRunLoop

Viewed 7435

My app tracks a user with CLLocationManager. In the delegate call didUpdateToLocation I do all the fun stuff of saving their position. However, I needed a way to test if they had stopped. That away I could stop recording locations and consider their trip over. So I have a NSTimer in CCLocationManager that gets added and removed every time didUpdateToLocation is called. That away it will be initiated when the user stops and CLLocationManager stops getting called.

The only way that I could ever get the NSTimer to work is to do:

[[NSRunLoop mainRunLoop] addTimer:userStoppedMovingTimer forMode:NSRunLoopCommonModes];

Then to remove it:

[userStoppedMovingTimer invalidate];

I've never had to add timers like this in the past. Could someone shed some light as to why this is?

1 Answers
Related