Cocoa Tutorial for Beginners
Cocoa Application Tutorial
Contents
Figures and Listings
Introduction
The Essence of Cocoa
What Is Cocoa?
Classes and Objects
The MVC Design Pattern
Model Objects
View Objects
Controller Objects
Hybrid Models
The Currency Converter Application
Creating a Project in Xcode
Open Xcode
Make a New Project
Choose the New Project Command
Choose a Project Type
The Xcode Project Interface
What's Next?
Defining the Model
Specify the Model Class
Declare the Model Interface
Declare Member Variables
Declared Properties and Accessor Methods
Declare the Model Method: convertCurrency
Implementing the Model
Define the convertCurrency Method
What's Next?
Defining the View: Building the User Interface
User Interface Elements and Interface Builder
What Is a Nib File?
Windows and Menus in Cocoa
Key and Main Windows
NSWindow and the Window Server
Application, Window, View
Creating the Currency Converter Window
Create the Window
Resize the Window
Change the Title of the Window
Add the Text Fields
Assign Labels to the Fields
Change the Text Field Attributes
Configure a Button
Add a Separator to Group Controls
Refining the Layout and View Functionality
Configure the Menu
Aligning Objects in a Window
Finalize the Window Size
Enable Tabbing Between Text Fields
Set the First Responder Text Field
Test the Interface
What's Next?
Bridging the Model and View: The Controller
Paths for Object Communication: Outlets, Targets, and Actions
Outlets
Target/Action in Interface Builder
Which Direction to Connect?
Defining the Controller Class
Defining the Outlets for the ConverterController Class
Implementing the Controller Method: convert:
Interconnecting the Controller with the View
Add the ConverterController Class to Your Nib File
Connect the ConverterController Instance to the Text Fields
Connect the Convert Button to the Appropriate Methods
Check Your Work
Connecting the Controller with the Model
Garbage Collection
What's Next?
Building and Running Your Application
Build the Application
Extra: Check Out the Look Up Documentation
Run the Application
Correct Build Errors
Great Job!
What's Next?
Configuring Your Application
The Info.plist File
Basic Project Attributes
Specify the Identifier, Version, and Copyright Information
Create an Icon File
What's Next?
Expanding on the Basics
For Free with Cocoa
Application and Window Behavior
Controls and Text
Menu Commands
Document Management
File Management
Communicating with Other Applications
Custom Drawing and Animation
Internationalization
Editing Support
Printing
Help
Plug-in Architecture
Turbo Coding with Xcode
Project Find
Code Sense and Code Completion
Integrated Documentation Viewing
Indentation
Delimiter Checking
Emacs Bindings
Appendix A: Objective-C Quick Reference Guide
Messages and Method Implementations
Declarations
Revision History
Software Archive