问题
Hey I got a pretty low interval timer in my firstViewController which I would like to terminate when the app enters background, but how am I supposed to access it from my Applications AppDelegate file where the function is located. I know this is extremely dumb question, but I would appreciate help. Thanks!
回答1:
In your firstViewController, you would listen for UIApplicationDidEnterBackgroundNotification.
In the firstViewController init method:
- (void)addObserver:(id)notificationObserver selector:(SEL)notificationSelector name:(NSString *)notificationName object:(id)notificationSender
来源:https://stackoverflow.com/questions/5327278/application-did-enter-background-function