Cocoa Development
... an introduction
by Lieven Dekeyser
Part 2
- AppKit
- Interface Builder
- "Learn by example"
AppKit
- User Interface components
- Document-based applications
- Graphics (bezier paths, transformations, images, OpenGL,...)
- Printing & other system services
- Cocoa Bindings (NSObjectController, NSArrayController,...)
Interface Builder
- "draw" user interfaces...
- ... and connection to the code
- No code generation
- NIB-files de-serialized at runtime
Example: Currency Converter
- Demo time
- Parts of code Interface Builder recognizes:
- Actions: instance methods with
IBAction
- Outlets: instance variables with
IBOutlet
- Connections are checked at runtime (though XIB compiler helps)
- Copy/Paste, Undo/Redo,... all magically work?
Responder chain
- Actions can be sent to the responder chain:
- In Interface Builder, connect to actions of the First Responder object
- Menu items enable/disable depending on the current responder chain
Example: WebView Playground
- Demo time
- Use of external framework
- Easy to integrate a web application
Example: Text Editor
- Demo time
- Document-based application
- 2 XIB-files: one for application, one for each document.
- NSDocument subclass to control:
- Reading/writing data
- Passing data to views
- Info.plist defines the document types an application can handle
- Responder chain also includes the NSDocument object