I was looking into a debug file my application creates while running and saw a strange behavior:
The application uses NSURLConnction
to retrieve some data from a server. The connection was started and then the user moved application to the background probable by pressing the home button (application:willResignActive
and application:didEnterBackground
methods were called).
I could see that the connection was handled in my code after application:didEnterBackground
was called. (The connectionDidFinishLoading
of NSURLConnection
delegate was called after application:didEnterBackground
). In the implementation of connectionDidFinishLoading
I perform some operations, but at this point application was probable suspended and the code wasn't called.
Then after almost 12 hours user launched application again (it wasn't terminated, but only was in the background) and the code continued running from the same point it stopped, even before application:willEnterForeground
and application:didBecomeActive
were called).
Does it make scenes?
The part of code running before application entered to the foreground changed my application internal state and cause to strange behavior.
Any ideas how to solve it?