從 Windows 10 年轉向 Mac + Xcode + Objective-C,快捷鍵、IDE 操作、鍵盤手感均需重新適應。
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"Hi, FansUnion!");
}
return 0;
}
輸出:
2015-11-15 11:36:44.984 switch[1410:50516] Hi, FansUnion!
Program ended with exit code: 0
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
int n=0, sum=0;
for (n=1; n<=10; n++) sum += n;
NSLog(@"The sum is %i", sum);
}
return 0;
}
輸出:
2015-11-15 11:08:42.517 for[1242:40319] The sum is 55
Program ended with exit code: 0
@、[]、NSLog),但 C 兼容性好。