Cover Page by Stephen G. Kochan

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

2. Programming in Objective-C

In this chapter, we dive right in and show you how to write your first Objective-C program. You won’t work with objects just yet; that’s the topic of the next chapter. We want you to understand the steps involved in keying in a program and compiling and running it.

To begin, let’s pick a rather simple example: a program that displays the phrase “Programming is fun!” on your screen. Without further ado, Program 2.1 shows an Objective-C program to accomplish this task..

Program 2.1

// First program example#import <Foundation/Foundation.h>int main (int argc, const char * argv[]){   @autoreleasepool {      NSLog (@"Programming is fun!");   }   return 0;}

Compiling and Running Programs

Before we go into a detailed explanation ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required