Cocoa FAQ

From Mac Guides

Jump to: navigation, search

Cocoa is the official API of Mac OS X and the iPhone, supported by Apple.

Contents

General

I've never programmed before. How should I start learning Cocoa?

If you are serious about learning Cocoa and have never programmed before, it is strongly advised you learn the C language first, since Objective-C is a proper superset of C. After you are familiar with C, Objective-C will be easier. However it is not necessary to learn C immediately.

The standard reference book for C is "The C Programming Language" by Kernighan and Ritchie. There are also many online references to help you get started. The Masters of the Void is an introductory tutorial for learning C written specifically for Mac users. In OS X you can use XCode or command-line tools such as gcc to build and run your C programs.

For Cocoa programming specifically, Apple has a guide to help you get started. There is also Cocoa Dev Central which gives an easy to follow guide to both Interface Builder and Xcode.

What should I use to write Cocoa Applications?

Whatever level you are it is recommended to use Xcode. Even if you aren't using Cocoa it is strongly recommended to install Xcode for any development work, even if you don't use it as it also installs general development resources.

Where do I get Xcode?

You can install the version of Xcode that was current at the time your Mac shipped by installing "Developer Tools" from the second grey disc that came with your Mac, usually labelled "optional installs."

Older versions of Xcode (v3.x and v4.x) are available from Apple's Developer Download site with an ADC account (free or paid).

Xcode 5 is the most recent version and available from the Mac App Store for free.

It is recommended to use a more recent version of XCode (v4.x or 5.x), as most current learning resources are designed around these versions.

Where do I register for a free ADC membership?

Apple highlights the paid US$99 Mac and iOS developer plans which allow you to submit your apps to the store, however ADC membership is free. The registration page for the free program is available at this direct link. The free ADC membership provides access to the latest version of Xcode 3 and many other resources, but does not allow you to submit apps to the App Store or Mac App Store.

What book do you recommend for learning Cocoa?

For those with some programming background, the most popular book is Cocoa Programming for Mac OS X, by Aaron Hillegass and has been updated for Leopard, Xcode3 and Objective-C 2.0.

If you do not have any previous programming experience, you may wish to use another book to learn Objective-C first. Programming in Objective C 2.0 by Steve Kochan or Objective-C Programming by Aaron Hillegass are both good options.

Other Cocoa/Objective C books are available from publishers such as Apress and O'Reilly.

What languages can I use to write Cocoa applications?

The official native language is Objective-C. However, Leopard includes bindings for Ruby and Python.

I have a background in Java/C++/C#/etc, how hard is it to learn Objective-C?

Objective-C is an easy language. You will be able to pick it up in about a day. Developers may feel more at home using Objective-C 2.0 (new in Leopard) which uses dot notation for properties.

Is there support for C++?

Cocoa does not support C++ directly. However, you can write applications using a mixture of C++ and Objective-C, formally called Objective-C++. (NOTE: The link is dead and there is nothing about Objective C++ in the document you are forwarded to).

Where is the language documentation?

The language documentation is available through Help>Documentation in Xcode and Apple's Objective C documentation site. Searching for <<class name>> site:apple.com on Google will get you straight to the class you want.

iPhone

What do I need to start writing iOS/iPhone applications?

You should first have an understanding of Objective-C and Cocoa programming, as detailed above.

Apple provides a special area of their developer site for iPhone programming. From there, you can download the iOS SDK (ADC account required), though it may already have come bundled with Xcode if you downloaded that from ADC

You will also need and Intel Mac running OS X (Snow) Leopard. An iPhone or iPod touch is not required as Xcode with the iOS SDK provides a hardware emulator for you to test your code on.

There are also many other iOS development specific resources online such as the iTunes U course from Stanford University