12.7 Lösung: Delegate-Methoden aufrufen

Das ist mal wieder eine von diesen Übungen, deren Beschreibung mehr Zeit erfordert als die eigentliche Lösung. Hier die Änderungen an applicationDidLaunch: und applicationDidTerminate::

Protocols/HelloApplication9/CurrentApp.m

-(void) applicationDidLaunch: (NSNotification *) notification {
    if ([self.delegate
            respondsToSelector:@selector(applicationDidLaunch:)] ) {
        [self.delegate applicationDidLaunch:self];
    }
}

-(void) applicationDidTerminate: (NSNotification *) notification {
    if ([self.delegate
           respondsToSelector:@selector(applicationDidTerminate:)]) {
        [self.delegate applicationDidTerminate:self];
    }
}

Sie müssen außerdem ActivityMonitorDelegate.h in die CurrentApp-Header-Datei importieren. Sie hätten auch eine ...

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.