views:

601

answers:

4

I am currently learning objective-c and cocoa. Next, I want to stick up to iPhone programming. I'll get a book for that, of course. But I would like to know already now, which main differences are there between cocoa and cocoaTouch.

A: 

From what I understand, one of the main differences is that cocoa has its own version of Garbage Collection (managed memory like .NET), but cocoaTouch does not.

Mike_G
CocoaTouch has reference counting for the memory. Cocoa has an optional garbage collector, but only for Mac OS X >= 10.5
Georg
A: 

Basically it's just the frameworks that are available to you. For desktop development you would use AppKit and for iPhone development you use UIKit. UIkit obviously includes the multitouch features etc.

When you get started on iPhone development, here's a FAQ that might come in handy: http://www.plaidworld.com/iphonefaq.txt

Edit: And yes, like the post above mentions, even though Objective-C 2.0 is available for iPhone development, there is no GC

nduplessis
+6  A: 

The core concepts of Cocoa and Cocoa touch are similar, in that there is a view hierarchy and responder chain. However, the UIView architecture is much more closely tied to the more recent technologies such as CoreAnimation.

The types of controls that are available also change.

Additionally, Cocoa touch introduces the concept of UIViewControllers, which create a nice abstraction for putting code that interacts with your main program and the specific view it owns. As Chuck pointed out in the comments, this was added in Cocoa in Mac OS X 10.5, so depending on how you learned Cocoa you may or may not be aware of them.

Finally, as others have mentioned, Garbage Collection does not exist on the iPhone currently.

NilObject
Cocoa has NSViewController now, so that's not really a difference.
Chuck
Thanks for pointing that out, for some reason I was oblivious to that (probably that I haven't done desktop Cocoa since the iPhone SDK came out).
NilObject
+3  A: 

To add to what others have said, much of the foundation is shared between Cocoa Touch and Cocoa. For example, data type classes like NSString and collection classes like NSArray are identical in both frameworks. Other classes like NSURLConnection are substantially the same. Other high-level frameworks, like Core Data for example, are absent from Cocoa Touch.

Also, Cocoa Touch was developed with Objective-C 2.0. So UIKit, the Cocoa Touch framework counterpart to AppKit in Cocoa, makes extensive use of properties. In many ways, Cocoa Touch is more modern than Cocoa. Cocoa Touch also tends to use the Objective-C @protocol syntax instead of the older category syntax for implementing what Apple calls "informal protocols" (i.e. protocols where some methods are optional)

Alex