Cocoa or Objective-C?

You've got it a little wrong.

NSTimer, NSString, NSMutableArray are all Cocoa. int and float are actually C, but since Objective-C is a strict superset of C, you are able to use them in your Objective-C code.

Pure Objective-C requires linking only to the Objective-C runtime library and no other frameworks or libraries. Cocoa is a framework that includes things like NSObject and NSString. Other frameworks, like AppKit, extend the Cocoa framework.

Coding in pure Objective-C usually means deriving from the root object called Object and not NSObject. Things like @implementation, @interface, @selector etc. are the Objective-C extensions to C and these are what are common in all Objective-C source, pure or not. If you want to code in pure Objective-C you cannot use anything other than your own objects derived from Object.

#import <objc/Object.h>

As already pointed out, The NS* classes are actually Cocoa, not Objective-C. Objective-C is a language, while Cocoa is a framework (an implementation of OpenStep). This framework can be considered to be the "stdlib" equivalent of C++. The UI* classes are Cocoa Touch, another framework created for the iPhone.

As to the last question, yes, Cocoa Touch is for the iPhone only. Cocoa is for Mac OS X development. However, as stated above, Cocoa is an OpenStep implementation. Alternatives to Cocoa exist, such as GNUstep and Cocotron. These alternative frameworks allow to use the same code on multiple platforms. The OpenStep frameworks are therefor not only for Mac OS X development, but can also be for Linux and Windows.

Another thing to note is that other Objective-C runtimes are different. There is no single Objective-C specification. The Portable Object Compiler is yet another way of doing this. Since Apple is the dominant user of Objective-C, and it controls Cocoa, it's considered the de facto Objective-C implementation.


It's true that Cocoa Touch is for iPhone development and "plain" Cocoa for Mac OS X development, but they're not very different and share most of basic classes.

In iPhone development you don't need to care whether you're using pure Objective-C or Cocoa. Cocoa is 1st class citizen on iPhone and you don't gain anything by avoiding it.

There is a slight difference between Objective-C and plain old C subset. Object allocation and method calls have higher overhead than stack-allocated structures and direct function calls, but 99% of the time you don't need to care about this either (don't try to optimize prematurely!).