1 #import <Foundation/Foundation.h>
2
3 int main (int argc, const char * argv[]) {
4 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
5
6 // insert code here...
7 NSLog(@"Hello, World!");
8 [pool drain];
9 return 0;
10 }
Line 1 is an #import statement, which behaves just like it does in Java, or like #include in C/C++
Line 3 is main... which should look familiar from countless other languages
Line 4 creates a "pool" of memory so that your program can use it
Line 6 is a one line comment. Multiple line comments follow the /* text */ format, like most languages
Line 7 is a print statement. The @ makes this line a format string as opposed to a C string
Line 8 gives the borrowed memory back to the machine
Line 9 is the return statement for this program (used to pass errors to the operating system)
This made me remember my programming days.
ReplyDeleteNice post; it's great for the less technologically inclined in the area of coding to get a feel for what each line does.
ReplyDeleteNice one! Did some programming for a while..getting a but rusty though :P
ReplyDelete+1 follower :)
I don't know if I like a language that has a pointer in its "Hello World" program...
ReplyDelete