swift 2
2015-12-22 11:21
381 查看
...
..<
func a(inout a) //by ref use &xx
Parameters passed to functions are constants by default, which means they can't be modified.
func incrementAndPrint(var value: Int) { //var 可修改,传值
value++
print(value)
}
Closure
var multiplyClosure: (Int, Int) -> Int
multiplyClosure = { (a: Int, b: Int) -> Int in
return a * b
}
multiplyClosure = { (a, b) in
a*b
}
multiplyClosure = {
$0 * $1 }
if you are using an optional type then you know you must handle the nil case
optional
let binding
Nil coalescing ??
计算属性可以用于类、结构体和枚举里,存储属性只能用于类和结构体
使用关键字 static 来定义值类型的类型属性,关键字 class 来为类(class)定义类型属性
@objc 可以让你的 Swift API 在 Objective-C
..<
func a(inout a) //by ref use &xx
Parameters passed to functions are constants by default, which means they can't be modified.
func incrementAndPrint(var value: Int) { //var 可修改,传值
value++
print(value)
}
Closure
var multiplyClosure: (Int, Int) -> Int
multiplyClosure = { (a: Int, b: Int) -> Int in
return a * b
}
multiplyClosure = { (a, b) in
a*b
}
multiplyClosure = {
$0 * $1 }
if you are using an optional type then you know you must handle the nil case
optional
let binding
Nil coalescing ??
计算属性可以用于类、结构体和枚举里,存储属性只能用于类和结构体
使用关键字 static 来定义值类型的类型属性,关键字 class 来为类(class)定义类型属性
@objc 可以让你的 Swift API 在 Objective-C
相关文章推荐
- swift 学习记录(静态方法)
- swift学习日志——输入输出参数
- Ubuntu14.04安装swift2.2
- 利用Swift之协议语法实现页面间的传值功能
- dyld: Library not loaded: @rpath/libswiftCore.dylib报错解决
- swift 学习记录(实例方法)
- 窥探Swift之协议(Protocol)和委托代理(Delegate)回调的使用
- Swift 函数(笔记)
- swift-基础08-隐式解析,隐式装包,强制装包和断言
- swift-基础07-if语句,强制解析与可选绑定和nil
- Swift 命名规则
- Swift 数据类型
- iOS --- Swift中泛型(Generic)的基本使用
- iOS集成丁香园DXY OAuth 登陆 swift代码示例
- swift中判断设备是否打开定位
- 项目开发笔记-2015.12.21-swift
- Swift Tutorial: Repeating Steps with Loops
- swift 新功能介绍
- Swift 已经正式开源了! 你了解到了吗?
- Swift 设置按钮圆角 代码&Xib