简体   繁体   中英

In App Delegate call method from another class

I have a view which contains scroll view with some subviews (UIViewControllers). I want to call a method (stop timer) from a class, one of their UIViewControllers, in applicationWillResignActive: method of App Delegate.

What's the best way to implement this?

Don't worry about handling that event in your app delegate and passing it on. Just register for a notification in whatever class you're interested in handling the event from:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM