Bookmark and Share

Objective-C Programming Tutorial


Before anything else, I think, we need to be familiar with Xcode.
Xcode is tools for developing software on Mac OS X. Xcode 3.2, the latest major version, is bundled free with Mac OS X v10.6, but is not installed by default. The version that is currently available is 3.2.2 that comes with iPhone SDK 3.2. Xcode 3.2.3 for iPhone SDK 4.0 has been released in beta.
Because version 3.2 is not supported on older Mac OS versions, more dated versions of Xcode are available free from the Apple Developer Connection website.




XCode Tutorial

XcodeIcon

Xocde is located in Developer/Applications folder.

WhereIsXcode



Start Xcode and select New Project under the File menu.

NewProject

Scroll down until you get to Command Line Utility.

NewProjectWindow

Highlight Foundation Tool and press Choose....

NewProjectSave


Type in Project Name and click Save. Then you will have a Project window as in the picture below.

myFirstCodeProjectWindow

Now it's time to type in your first Objective C program. Select the myFirstCode.m. Your Xcode window wil appear as shown in the picture below.

myFirstCode.m

The *.m is used for Objective-C source file and *.mm is used for Objective-C++ source file.
To compile and run, click Build and Go.


But you can use command line to compile and run your code.


To compile:

 $ gcc -framework -Foundation myFirstCode.m -o myFirstCode 
To run:
 $ ./myFirstCode 
Then you will get:
 2010-04-24 20:51:01.056 myFirstCode[322:807] Hello, World! 

However, if you want make iPhone applications, there's more to just the executable file that needs to be packaged into an application bundle. So, learning how to use Xcode will be well worth it in developing iPhone apps.