Reputation: 1334
So, I have an NSTimer
that is set to call a selector every second:
timer = [NSTimer scheduledTimerWithTimeInterval:1.0f
target:self
selector:@selector(TimerSelector:)
userInfo:nil
repeats:YES ];
This is all fine, but ever since I updated to iOS 8, I've noticed that this selector keeps getting called even after the application goes to the background. I thought that it would eventually stop running, as I believe an iOS application isn't allowed run in the background without a reason, but the selector kept getting called. I tried keeping the application on and simulating memory warnings, but the selector kept getting called for over 6 hours.
This behavior was only exhibited in iOS 8 and not iOS 7. Is this normal? Did iOS 8 bring something new I'm not aware of?
Upvotes: 1
Views: 123
Reputation: 535191
It sounds like it might be an exciting and interesting change in iOS 8, but I'm afraid that it is just a bug in the simulator. There's no evidence of timers continuing to run in the background on the device, which is all that really matters.
The situation on the device is that, unless your app has some other reason to run in the background, the timer is paused while your app is in the background, and resumes when your app comes to the foreground, just as in the previous system.
In the iOS 8 simulator, however, there's a well-known bug (Apple shows awareness of it in Dev Forums posts from November and December 2014): tasks continue to run and are not suspended when the app is backgrounded. Take no notice! The simulator is just a simulator. Do your real testing on a device.
Upvotes: 2