Cocoa Training Module 2 by sourabhdua88

VIEWS: 99 PAGES: 11

Cocoa Training in Modules

More Info
									

Introduction to Cocoa Application
Development
Module 2: Creating Your First Cocoa Application




All Materials © 2008 Apple Inc. All Rights Reserved.
Exercise #1 - Create an Xcode Project




■ Currency Converter
 -   Convert US Dollars to Another Currency Based on
     Exchange Rate
Exercise #1 Notes
■ Xcode has Templates for Many Project Types
  -   Cocoa, Carbon, Command Line Tools, Kernel Extension

■ Xcode Project Interface
  -   Groups & File List - Navigate The Files that Make Up Your
      Project

  -   Targets - All the Products your Project Builds

  -   Executables - Stand Alone Executables

  -   Errors & Warnings - Any Build Errors or Warnings
Exercise #2 - Defining the Model

■ Declare Member Variables
■ Write Accessor Methods
  -   Provide Access to Get & Set Instance Variables

■ Declare & Implement Method
■ Pay Attention to Syntax
  -   Case Sensitive Names
      -   eg. myArray is not the same as MyArray

  -   Parenthesis and Curly Brackets must match

  -   Many compiler errors caused by spelling, capitalization and
      punctuation mistakes
Exercise #2 Notes

■ Classes Decide Which Instance Variables They
  Provide Accessors For
  -   Some ivars May Be Read Only



■ Accessor Nomenclature
  -   Getters & Setters
Exercise #3 - Define the Interface
■ Use Interface Builder to Define GUI & Object
  Connections
■ Nib File
  -   Every Cocoa GUI application has at least one
      -   Loaded Automatically when Application Starts

      -   Menu Bar, At Least One Window, Other Objects

  -   Archived Objects
      -   “Serialized” to Disk to Maintain State
Exercise #4 - The Controller
■ Controller Provides Communication Between
  Model & View
■ Outlets - An Instance Variable That Identifies An
  Object




 ■ Declared in Your Header File with IBOutlet
   Keyword

  IBOutlet NSTextField *amountField;


 ■ Connected in Interface Builder
Exercise #4 - The Controller (ctd.)
■ Controls Send Messages to Objects via Target/
  Action Connection
  -   Target - An Outlet To The Object That Receives Message

  -   Action - The Method To Invoke




      - (IBAction)convert:(id)sender;
Exercise #5 - Run Application




■ Learn to use Xcode to Build and Run Your
  Application
Exercise #6 - Configure Application
■ Information Property List file (Info.plist)
  -   application-name

  -   application-identifier

  -   application-icon-filename

  -   release-version-number

  -   build-version-number

  -   copyright-text
Exercise #7 - Runtime Debugging
■ GDB - GNU Debugger
■ Use ‘Debug’ Build Configuration
 -   ‘Generate Debug Symbols’ Build Setting

■ Has Many Powerful Features
 -   Breakpoints
     -   Actions, Conditional Breakpoints

 -   Code Stepping

 -   Object Inspection

								
To top