Created
June 13, 2017 16:56
-
-
Save OctoberHammer/67784c48a7ba18cd309c2a0c9c4f5382 to your computer and use it in GitHub Desktop.
callBack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Foundation | |
class ConnectBLE { | |
var callBackFunc: ()->() | |
init(callFunc: @escaping () -> ()){ | |
callBackFunc = callFunc | |
} | |
} | |
let inst = ConnectBLE(callFunc: {print("Hello world")}) | |
inst.callBackFunc() | |
let inst1 = ConnectBLE {print("Hello Another world")} | |
inst1.callBackFunc() |
Ща
Нет, не работает. Error: use of unresolved indentifier self.
да, сек,
class ConnectBLE {
var callBackFunc: ()->()
init(callFunc: @escaping () -> ()){
callBackFunc = callFunc
}
func runCallBackFunc() {
callBackFunc()
}
}
class DelegateARC {
static func RaspakHC05() -> () {
print("awesome")
}
let object = ConnectBLE(callFunc: {DelegateARC.RaspakHC05()})
}
let myInst = DelegateARC()
myInst.object.runCallBackFunc()
======
Пришлось
а) пометить RaspakHC05 как статик, иначе не компилось, ви в общем понятно почему
б) убрать у object приват, иначе никак не проверить работоспособность
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
спасибо, сейчас попробую