objective c

Objective-C Program Structure

« Previous Tutorial Next Tutorial »

An Objective-C program generally consists of the these parts:

Objective-C Program Structure Example

Here is an example program to understand the basic structure of an Objective-C program:

/* Objective-C Program Structure - Example Program */
#import <Foundation/Foundation.h>
@interface SampleClass:NSObject
- (void)sampleMethod;
@implementation SampleClass
- (void)sampleMethod
   NSLog(@"Hello, World \n");
int main()
   SampleClass *sampleClass = [[SampleClass alloc]init];
   [sampleClass sampleMethod];
   return 0;

How to Compile and Execute an Objective-C Program ?

When the above program is compile and executed, it would produce the following result:

2009-06-03 13:18:37.932 demo[28001] Hello, World

Now let's look at various parts of the above program :

« Previous Tutorial Next Tutorial »


Quick Links
Signup - Login - Give Online Test