With Objective C memory management, we have the general rule that if you create an object with any of the following techniques, you need to release the object later.
- alloc
- new
- copy
- mutableCopy
This rule is simple to remember. I'm looking for a analogous simple rule for deciding whether something does background processing when the app sleeps. Does such a definitive list exist?
- NSUrlRequest - if you send a request out then hit the home button right away, is it possible that my app still processes the server response?
- Timer - you set off a timer to fire 1 minute from now, but you hit the home button before 1 minute elapse. Does the timer still run, does it get paused, or does it get canceled?
- For loop - you write a for loop that does a million iterations. You close the app after it's done with 600,000 iterations. What happens to the rest of the 400,000 iterations when the app sleeps and when you re-open the app?
- And so on...
There's a dozen other things I'm thinking about whenever the app sleeps. I'm worried because ever since I started developing this video camera app, my battery life has been horrible (dropping 50% overnight). Maybe it's a coincidence or maybe the camera is still recording while the app is sleeping.