11.10 Lösung: Eigene Notifikationen empfangen

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 ...

Get Cocoa-Programmierung now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.