14.13 Lösung: View und Modell verknüpfen

Wir haben Eigenschaften in die Header-Datei eingefügt:

MultipleNibs/HelloApplication21/MyWindowController.h

#import <Cocoa/Cocoa.h>
@class CurrentApp;
@class ActivityController;

@interface MyWindowController : NSWindowController {
    CurrentApp *currentApp;
    ActivityController *ac;
}
@property CurrentApp *currentApp;
@property ActivityController *ac;

@end

Sehen wir uns die Implementierung genauer an:

MultipleNibs/HelloApplication21/MyWindowController.m

 1  #import "MyWindowController.h"
 2  #import "ActivityController.h"
 3  #import "CurrentApp.h"
 4
 5  @implementation MyWindowController
 6
 7  @synthesize ac, currentApp;
 8
 9  -(void) setUpView {
10      self.ac = [[ActivityController alloc]
11                   initWithNibName:@"ActivityView"

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.