object-c Hello World实例

这里示范一个基础的Hello World程序。

#import<Foundation/Foundation.h>
 
int main(int argc, char *argv[]){
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 
    NSLog(@"Hello World!");
 
    [pool drain];
    return 0;
}
以上是Xcode的旧版"Hello World"程序代码,在4.3.1 xcode的代码为:

#import <Foundation/Foundation.h>
 
int main(int argc, char *argv[]){
    @autoreleasepool{
        NSLog(@"Hello World!");
    }
  return 0;
}

comments powered by Disqus