Hello is it possible to make a callback like such? I want to pass a function as a parameter to be able run the callback function after some task is finished.
class ConnectBLE { var callBackFunc: ()->() init(callFunc: @escaping () -> ()){ callBackFunc = callFunc } func runCallBackFunc() { callBackFunc() } } class DelegateARC { private let object = ConnectBLE(callFunc: RaspakHC05) func RaspakHC05() { print("hello from a callback") } } But I'm having an error. Cannot convert value of type '(DelegateARC) -> () -> ()' to expected argument type '() -> ()'
selfin a non-lazy property initializer, as they are run before your object is initialized. Try:private lazy var object: ConnectBLE = ConnectBLE(callFunc: self.RaspakHC05)