OC初步 (一)

  OC完全兼容C, 代码后缀名一般习惯用 *.m 或 *.mm,按惯例从 "Hello,World!" 开始,我们编写一个 test.mm 文件如下:

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

  OC使用 clang 作为编译器,此外编译OC程序需要链接 Foundation 库(通过 -framework 参数来指定库),即编译命令如下:

clang test.mm -o test -framework Foundation

  swift 的示例代码为 test.swift 如下:

print("Hello,World!")

   执行命令为:

swift test.swift
原文地址:https://www.cnblogs.com/tianyajuanke/p/5528042.html