Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Sie kennen die einzelnen Schritte dieser Übung. Fassen wir also zusammen: die Methoden registerNotications und setUpNotication:withSelector: aus CurrentApp einfügen und registerNotications aus awake-FromNib heraus aufrufen.
Wenn Sie eine Notifikation empfangen, müssen Sie den Stringwert von activeDisplay auf „Launched“ oder „Terminated“ setzen.
Notication/HelloApplication6/ActivityController.m
#import "ActivityController.h" #import "CurrentApp.h" @implementation ActivityController @synthesize currentApp, activityDisplay; -(void) applicationDidLaunch: (NSNotification *) notification { [self.activityDisplay setStringValue:@"Launched."]; } -(void) applicationDidTerminate: (NSNotification *) notification { [