Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tiaan3365

macrumors newbie
Original poster
Jan 8, 2013
3
0
Good day all

I would like to know if you can change a method in my app delegate on an event in another class.

I basically want to add a local notification to the didenterbackground method on a time set on another form.

I hope someone could help.
 
That method call is a response from UIApplication and thus only calls in the app delegate. If you want another class to react to the enter background you can have it register a selector on the notification center.

Code:
[[NSNotificationCenter defaultCenter] addObserver: self
                                         selector: @selector(handleEnteredBackground:) 
                                             name: UIApplicationDidEnterBackgroundNotification
                                           object: nil];

Code:
- (void)handleEnteredBackground:(NSNotification*)notification
{
    //Your Logic
}

NOTE: Be sure to remove the observer from your class when it is dealloced or the view is removed from the hierarchy.

The specific key is the :UIApplicationDidEnterBackgroundNotification

These are all notifications you can register in other classes with notification center.

Code:
UIApplicationDidBecomeActiveNotification
UIApplicationDidChangeStatusBarFrameNotification
UIApplicationDidChangeStatusBarOrientationNotification
UIApplicationDidEnterBackgroundNotification
UIApplicationDidFinishLaunchingNotification
UIApplicationDidReceiveMemoryWarningNotification
UIApplicationProtectedDataDidBecomeAvailable
ApplicationProtectedDataWillBecomeUnavailable
UIApplicationSignificantTimeChangeNotification
UIApplicationWillChangeStatusBarOrientationNotification
UIApplicationWillChangeStatusBarFrameNotification
UIApplicationWillResignActiveNotification
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.