Swift 基本语法.pdfVIP

  • 16
  • 0
  • 约3.04千字
  • 约 5页
  • 2017-05-29 发布于浙江
  • 举报
Swift 基本语法

Swift 基本语法 Swift 基本语法 在上⼀章节中我们已经讲到如何创建 Swift 语⾔的 Hello , World ! 程序。现在我们来 复习下。 如果创建的是 OS X playground 需要 ⼊ Cocoa : import Cocoa /* 我的第⼀个 Swift 程序 */ var myString = Hello, World! print(myString) 如果我们想创建 iOS playground 则需要 ⼊ UIKit : import U Kit var myString = Hello, World! print(myString) 执⾏以上程序,输出结果为: Hello, World! 以上代码即为 Swift 程序的基本结构,接下来我们来详细说明结构的组成部分。 Swift 引⼊ 我们可以使⽤ import 语句来 ⼊任何的 Ob ective-C 框架 (或 C 库)到 Swift 程序 中。例如 import cocoa 语句导⼊了使⽤了 Cocoa 库和API ,我们可以在 Swift 程序中 使⽤他们。 Cocoa 本⾝由 Ob ective-C 语⾔写成,Ob ective-C 又是 C 语⾔的严格超集,所以在 Sw

文档评论(0)

1亿VIP精品文档

相关文档