Hello World Cocoa
Want to be a Mac Developer? Well, OS X and Xcode makes it easy to start hacking your ideas into Apple applications. I started to ‘write’ a Hello World program using Xcode. In less than five minutes and no coding at all I was able to create what I had in mind:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSLog(@"Hello, World!");
[pool release];
return 0;
}
The above code was auto-generated for me by Xcode. Now only if Xcode could auto-generate the code for a new killer app that I been dreaming of.
I also want to note that the above code is a command line, Foundation Tool, application.
The @”Hello, World!” piece of code is a NSString literal. You night also have noticed that there are a lot of types that start with NS. The NS prefix stands for Next Step which is where Cocoa first started out.
Technorati Tags: object c, os x, mac developer, hello world