(1)变量与常量
(2)基本类型
(3)强制转换
(4)Bool类型
(5)元组
(6)可选值
-
- var str = "Hello, playground"
- let maxNum = 888
-
-
- var str1:String = "test"
- var int1:Int = 1
- var dou1:Double = 1.11
- var flo1:Float = 1.111111111111
-
-
- var dou2:Double = Double(int1) + dou1
-
-
- var bool1:Bool = true
- bool1 = false
- if bool1 {
- println("i am true")
- } else {
- println("i am false")
- }
-
-
- var registionResult = (name:"姓名",age:24,sex:"女")
- var connectionResult = ("404","Not Found!")
- registionResult.age
- registionResult.name
- registionResult.sex
-
- var registion:(name:String,age:Int,sex:String)
- registion.name = "xxx"
-
-
-
- var a:Int?
-
- a = 12
-
- a = "12".toInt()
-
- println("age is" + String(a!))
swift基础--变量
原文:http://www.cnblogs.com/isItOk/p/4873154.html