Between Cocoa and Cocoa Touch: A Comparative Introduction - Presentation Transcript
Between Cocoa and Cocoa Touch:
A Comparative Intro
lukhnos
Lithoglyph Inc.
2009-01-22
Topics Covered
•3 Essential Facts
• History
• What’s in Common
• What’s Different
• Migration Paths
Three Essential Facts
• Cocoa and Objective-C go together
• You need to know Foundation (NS.+) classes
• App Store on iPhone is the disruptive technology
History
NEXTSTEP
1989-1995
Mach, Objective-C
The “NS-” prefix
Mac OS X
1999-present
BSD userland
Quartz
Carbon
Cocoa
iPhone OS
2007
OS X under hood
Desktop-grade services
What’s in Common
• Main Development Language
• OS and Framework
• Design
• Tools
Main Developement Language
• Objective-C
• Child of Smalltalk, sibling of
Ruby
• “C with OO”
• Also, Objective-C++
OS and Framework
• Mac OS X essentials
• BSD userland
• CoreFoundation
• Quartz
• Foundation
• Core.+ system components
CoreFoundation
• C, refcount-based data type and system service library
• CFTypeRef family: array, dictionary, date, number, string...
• Runloop management, i18n, etc.
• CFNetwork stack
• Quartz and other Core.+ services share the same model
Foundation
• The basis of Cocoa (hence “Foundation”)
• All beginning with “NS” prefix (for historical reasons)
• Non-nil containers: NSArray, NSDictionary, NSSet etc.
• NSRunLoop, NSThread, etc., high-level system services
• NSUserDefaults, NSNotificationCenter, app-support
infrastructure
System Limitations
• Memory footprint
• App lifecycle
• Sandbox
• No inter-app communication
SDK Differences
• AppKit v.s. UIKit
• NSWindow/NSView v.s. unified UIView model
• Better, re-inforced MVC paradigm in iPhone SDK
Development Limitations
• No external framework
• No automatical garbage collection (GC) !
• Sandbox
• Code signing constraints
• Testing and distribution constraints
Some Things We’ve Learned
• Think in Objective-C 2.0
• Different platform for different use
• Maximize shared code base, sweat on platform
details
Think in Objective-C 2.0
• @property saves your poor fingers
• Fast enumeration also rocks
• Formal and optional protocol can lead to better design
• Also, in Cocoa, performSelector:onThread: etc. makes life
easier
Different Platform and Use
• “Your iPhone is not a Mac Pro”
• Think in bigger picture: Mobile-Web-Desktop integration
Shared Code Base?
• Cross-platform way of thinking helpful
• Thinkin 32/64-bit neutral code, Endian-agnostic, encoding-
agnostic, etc.
In Essence
• Objective-C is a must
• Know the shared libraries: Foundation, CoreFoundation
• Sweat the minor differences and details
Lukhnos gives a talk at a CocoaHeads Taipei talk on more
Lukhnos gives a talk at a CocoaHeads Taipei talk on January 22, 2009. He talks about the common traits of Cocoa and Cocoa Touch and differences between the two, and shares some thoughts of a developer that does both Mac and iPhone software development. less
0 comments
Post a comment