Question

Sorry if this is a dumb question, but I'm debugging a dangling pointer issue in my App and I need to know - Is it possible for the app to resignActive without first enterBackground? To becomeActive without first enterForeground?

My situation - I have class (called 'Connection') that manages all of the application's requests/connections. It needs to be available for as long as the app is alive, really.

In my -didFinishLaunchingWithOptions I init an instance of Connection and set some params. In my -applicationWillEnterBackground I suspend Connection's actions.

And, in my -applicationWillEnterForeground I check to see if the Connection instance still exists. If it does, simply resume actions, else a new one is created.

When I leave the app running for a while (an hour or so, with or without going back to the home screen), the app crashes with this error.

"2012-08-19 13:08:42.708 Picsilk[11108:707] *** -[Connection respondsToSelector:]: message sent to deallocated instance 0x24e120"

The class, 'Connection', is just a simple NSObject subclass, which manages an ASINetworkQueue instance and handles some specific needs I have for storing a user's tokens and authenticating requests to my api.

An instance of this class is created and managed by app delegate. My various view controllers use the app delegate to access the Connection, which automatically handles the queue (and non-queued requests as well)

Surely I'm missing something very simple and fundamental to my understanding of this SDK, please help. :]

Was it helpful?

Solution

The app can receive a UIApplicationWillResignActiveNotification when a call comes in or other notifications are presented. So, yes, it's possible "for the app to resignActive without first enterBackground".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top