Objective-C and Cocoa Warner Onstine President, Sandcast Software
sandcastsoftware.com
June 13, 2006
What is Objective-C? • Extension of C to provide an object-oriented interface • Developed as a reaction to the up and coming C++ development • Closely related to Smalltalk in ideas and some syntax • Originally developed by Stepstone software • Adopted by NeXT Computer for developing applications on NeXTStep sandcastsoftware.com
June 13, 2006
What is Cocoa? • • • • • • •
A set of libraries for interacting with OS X Foundation Kit AppKit Core Audio Core Image Web Kit (open source now) …plus many more
sandcastsoftware.com
June 13, 2006
Comparing Obj-C with Java • Java Interfaces and Objective-C Protocols • Types of Protocols – Formal and informal
• No there is no garbage collection – Init and alloc
sandcastsoftware.com
June 13, 2006
Protocols • Informal - NSTableDataSource • Formal - NSCoding
sandcastsoftware.com
June 13, 2006
Categories • Allows classes to override previously defined classes essentially replacing their implementation with a custom one
sandcastsoftware.com
June 13, 2006
Objective-C Class definitions • Header files • Implementation files
sandcastsoftware.com
June 13, 2006
Delegates • Similar to event listeners in Java land • Delegates can handle events and hand them off to other classes for handling
sandcastsoftware.com
June 13, 2006
Selectors • Selectors give the developer the ability to pass in a specific method to another class • Chapter 8 pg. 186
sandcastsoftware.com
June 13, 2006
UI Building • Introduction to Interface Builder
sandcastsoftware.com
June 13, 2006
Unit testing • OCUnit - was external, now bundled with Xcode – http://www.sente.ch/software/ocunit/
• UnitKit - created by James Duncan Davidson – http://unitkit.org/
sandcastsoftware.com
June 13, 2006
New features • Core Data • Cocoa bindings • Core Image
sandcastsoftware.com
June 13, 2006
Sample Application -iWorkout
sandcastsoftware.com
June 13, 2006
Resources • Learning Cocoa with Objective-C by James Duncan Davidson • Cocoa Programming for Mac OS X by Aaron Hillegass • Both excellent books for starting to learn programming on OS X
sandcastsoftware.com
June 13, 2006