Tuesday, November 27, 2007

The Hello World! program in Objective-C

//
// File: helloworld.m
//
// Programmer: Mihalis Tsoukalos
// Date: Friday 21 April 2006
//
// Use: gcc -Wall -lobjc helloworld.m -o helloworld
// to compile it.

#include <objc/Object.h>

@interface Mtsouk:Object

{

// This is left empty
// Usually, instance variables are declared here.
// In this example no instance variables
// need to be declared.

}

- (void)hw;

@end

#include <stdio.h>

@implementation Mtsouk

- (void)hw
{
 printf("Hello, World!\n");
}

@end

#include <stdlib.h>

int main(void)
{
 id myMtsouk;
 myMtsouk=[Mtsouk new];

 [myMtsouk hw]; 
 [myMtsouk free];
 return EXIT_SUCCESS;

}



Did you find the above information helpful? You will find a lot more information in my eBook "Programming Dashboard Widgets". The eBook describes how you can create Apple Dashboard Widgets using many programming languages including JavaScript, Perl, Objective-C, and PHP. You can buy it here.

No comments: