PDA

View Full Version : Obj-C + Cocoa




Nsutton
Jul 5, 2010, 07:28 PM
I just started learning Objective C today and It will be my third programming language (Python,C#).

I'm kinda confused about the whole cocoa thing. I know it a apple api for objective C but what does it add to the core language?
Does it change the syntax at all or require extra learning to use it?



jared_kipe
Jul 5, 2010, 11:50 PM
Objective-C is an extension to C that adds its own syntax for dealing with objects.

When programming on the Mac or iPhone platform there are quite a few "bonus" classes that you have access too, such as collection classes and strings/parsing.

Cocoa in the strictest sense is the graphical frameworks for laying out windows, buttons, text views, et'cetera...

The syntax is the same, but there are some paradigms to learn and love. Model-View-Controller being the biggest.

GorillaPaws
Jul 6, 2010, 12:05 AM
Cocoa in the strictest sense is the graphical frameworks for laying out windows, buttons, text views, et'cetera...

This is incorrect. Cocoa includes not only App kit (which is what you're describing above) but also the Foundation Framework which includes all of the non-graphical classes (NSObject, NSString, NSArray etc.). I hate to split hairs, but you did say "strictest sense," so I'm being persnickety.

Here's a link to the relevant documentation (http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW10).

jared_kipe
Jul 6, 2010, 04:09 PM
This is incorrect. Cocoa includes not only App kit (which is what you're describing above) but also the Foundation Framework which includes all of the non-graphical classes (NSObject, NSString, NSArray etc.). I hate to split hairs, but you did say "strictest sense," so I'm being persnickety.

Here's a link to the relevant documentation (http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW10).

You are correct. I guess Apple muddied the water when the iOS's version of Cocoa is called Cocoa Touch although the vast majority of the underlying Foundation level frameworks are the same or at least very similar, but the hither level frameworks for things like buttons or table views are completely different. I guess because of that I've always considered Cocoa as being the graphical frameworks.

In a lot of ways then, practically anything you use in Objective-C is Cocoa. Though Objective-C is available on other platforms, you don't get any of the useful classes.

ThaGrapist
Jul 6, 2010, 07:01 PM
In a lot of ways then, practically anything you use in Objective-C is Cocoa. Though Objective-C is available on other platforms, you don't get any of the useful classes.

The GNU project has implemented many of those useful classes in the open-source and portable GNUStep (http://www.gnustep.org/).