Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func test() {
- // c1
- // request() { (json: String?, errorCode: Int?) in
- // print("json", json!)
- // }
- // c2
- // request(completion: {(json: String?, errorCode: Int?) in
- // print(json!)
- // })
- // c3
- let myVar2 : Completion = { (json: String?, errorCode: Int?) -> () in
- print("json ", json!)
- }
- request(completion: myVar2)
- }
- typealias Completion = (_ result: String?, _ errorCode: Int?) -> ()
- func request(completion: Completion? = nil) {
- GET(completion: completion)
- }
- private func GET(completion: Completion? = nil) {
- if let callback = completion {
- callback("Thieu Mao", 1)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement