21.7 Das Modell unseres Bücherregal-Beispiels
Wir wollen uns das Bücherregal-Beispiel noch einmal ansehen. Dabei bewegen wir uns von Bindungen und Objekt-Controllern hin zu Bindungen mit Array-Controllern.
Legen Sie ein neues Cocoa-Projekt namens BookshelfWithBindings an und fügen Sie die PragBook
-Klasse mit den beiden Eigenschaften title
und author
(beides Strings) hinzu:
Bindings/BookshelfWithBindings/PragBook.h
#import <Cocoa/Cocoa.h> @interface PragBook : NSObject { NSString *author, *title; } @property (copy) NSString *author, *title; @end
Synthetisieren Sie die Eigenschaften in der Implementierung:
Bindings/BookshelfWithBindings/PragBook.m
#import "PragBook.h" @implementation PragBook @synthesize author, title; @end
Legen Sie eine Bookshelf
-Klasse ...
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.