Can i use below method somewhere other than AppDelegate ?if yes how?
- (void)applicationDidEnterBackground:(UIApplication *)application
Can i use below method somewhere other than AppDelegate ?if yes how?
- (void)applicationDidEnterBackground:(UIApplication *)application
This is a method of the UIApplicationDelegate
protocol, and can only be implemented by classes that conform to it.
You can set up a notification to other objects in your app from your app delegate by using the NSNotificationCenter
object:
- (void)applicationDidEnterBackground:(UIApplication *)application {
[[NSNotificationCenter defaultCenter] postNotificationName:@"didEnterBackground" object:self];
}
There is also the UIApplicationDidEnterBackgroundNotification
notification that you can listen for instead of doing the above.
Register the objects that you want to listen for the notification like this:
[[NSNotificationCenter defaultCenter] addObserver:someObject selector:@selector(someMethod:) name:@"UIApplicationDidEnterBackgroundNotification" object:nil];
No, But you can have other objects register for the UIApplicationDidEnterBackgroundNotification
notification. These objects will then be notified at the same time applicationDidEnterBackground:
is called.