- (void) applicationDidEnterBackground: (UIApplication * application)

Can I use the method below somewhere other than AppDelegate? If so, how?

- (void)applicationDidEnterBackground:(UIApplication *)application
+3
source share
2 answers

This is a protocol method UIApplicationDelegateand can only be implemented with the appropriate classes.

You can configure a notification for other objects in the application from your application delegate using the object NSNotificationCenter:

- (void)applicationDidEnterBackground:(UIApplication *)application {
   [[NSNotificationCenter defaultCenter] postNotificationName:@"didEnterBackground" object:self];
}

There is also a notice UIApplicationDidEnterBackgroundNotificationthat you can listen to instead of doing above.

Register the objects that you want to listen to for notification, for example:

[[NSNotificationCenter defaultCenter] addObserver:someObject selector:@selector(someMethod:) name:@"UIApplicationDidEnterBackgroundNotification" object:nil];
+8
source

, UIApplicationDidEnterBackgroundNotification. , applicationDidEnterBackground:.

+13

Source: https://habr.com/ru/post/1771362/


All Articles