views:

79

answers:

1

I am assuming I need to implement:

[[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(resignActive:)
                                                     name:UIApplicationWillResignActiveNotification
                                                   object:nil];

but am not sure if this is the right notification to determine my app is about to leave active state.

Is this a good place to cancel network connections, along with app termination?

+4  A: 

There are cases where UIApplicationWillResignActiveNotification is sent but the application does not enter the background, for example if a call is received but the user chooses not to answer it.

Use UIApplicationDidEnterBackgroundNotification to be notified when entering the background. Be aware that this will sometimes be sent after UIApplicationWillEnterForegroundNotification if the application is quickly opened again.

drawnonward