I am implementing facebook's SDK for iOS into my app. There are two functions however that are supposed to register and unregister for the notifications:
From Facebook's login to facebook with ios:
in the viewDidLoad method, register for the session change notification you defined in the app delegate by adding this code to the end of the method:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(sessionStateChanged:)
name:FBSessionStateChangedNotification
object:nil];
and
Unregister for the notifications by adding the following code to the end of the didReceiveMemoryWarning the method:
[[NSNotificationCenter defaultCenter] removeObserver:self];
Since I have quite a few view controllers and all of them should be using facebook's API, I thought I should implement the register/unregister methods in the applicationDidFinishLoadingWithOptions (for register
for notifications)
but I am not sure if and how I should implement the unregister
's removeObserver command, because applicationDidReceiveMemoryWarning is not available for the AppDelegate.
- Is DidReceiveMemoryWarning visiting all the viewControllers of the App?
- Would it be sufficient to unregister in just one of my viewControllers ?