Cocoa Development
... an introduction
by Lieven Dekeyser
Last time
- AppKit
- Interface Builder
- Reuse existing components
- Easy to build powerful applications
Part 3
- Custom Views
- Cocoa Bindings
- Key-Value coding
Example: Custom Views
- Demo Time
- Implement
- (void)drawRect:(NSRect)rect;
- NSBezierPath, NSGradient, NSShadow,...
- You can also use CoreGraphics
Example: Preferences
- Demo Time
- Bind control values to Shared User Defaults controller
- Storage in ~/Library/Preferences/<your.bundle.identifier>.plist
Key-Value coding
- Access an object's properties by its name
- (id)valueForKey:(NSString *)name;
- (void)setValue:(id)value forKey:(NSString *)name;
- Default implementation uses selectors for accessors:
- (id)<propertyName>;
- (NSString *)set<PropertyName>:(id)value;
Example: Table Views
- Demo Time: the old way
- Demo Time: using key-value coding
- Demo Time: using bindings