Learning Swift

2017-05-22

回调函数

下面这段代码是我摸索回调函数用法的过程写的,坑位如下

//: Playground - noun: a place where people can play

import UIKit

func applica(f: ((String) ->String), str: String)-> String {
    f(str)
    return "PVV"
    // output PVV
}

applica(f: {(str: String)->(String) in
    print(str)
    return str
    // printed abc
}, str: "abc")

回填函数在移动端牵扯到线程的问题。

Go Back

随便看看 :D