Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the main differences between Cocoa and CocoaTouch?

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 now already, what the main differences are between Cocoa and Cocoa Touch.

like image 558
Thanks Avatar asked Feb 26 '09 18:02

Thanks


2 Answers

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.

like image 173
Ecton Avatar answered Oct 06 '22 01:10

Ecton


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)

like image 21
Alex Avatar answered Oct 05 '22 23:10

Alex