-
Notifications
You must be signed in to change notification settings - Fork 874
CodeQuickRef
Liu Lantao edited this page Jun 12, 2014
·
5 revisions
如果有多个版本,使用xcode-select
将Xcode6设置为默认开发工具
sudo xcode-select -s /Applications/Xcode6-Beta.app/Contents/Developer/
直接开启swift控制台(非playground)
xcrun swift
声明常量:
let myConstant = 10
读作声明一个名为myConstant的常量,值为10
声明变量:
var myVariable = 0
读作声明一个名为myVariable的变量,初值为0
在常量或变量名后增加一个分号':',一个空格' ',以及类型名。
var welcomeMessage: String
读作声明一个名为welcomeMessage的String类型变量
如果声明时即为常量或变量赋值,则不必须加类型声明,因为Swift可以推断出合适的类型。
let alert: UIAlertView = UIAlertView()
alert.title = "This a simple UIAlertView"
alert.message = "Press OK to continue"
alert.addButtonWithTitle("OK")
alert.show()
-
Swift资源合集
- Introducing Swift by apple
- Xcode 6 beta 6 下载 by 网友
- Swift Beginner Guide by Lax