I'm a noob in the Swift-Universe, but I have to get the app running ;) It would be great if you help me to find a solution. Thanks a lot in advance.
The Problem occurs after upgrading to newer version of X-Code (Version 9.4.1) and Swift 4.
private var stoppedSuccessfully: (() -> Void)?
func stopRecording() -> Promise<Void> {
return Promise { success, _ in
self.stoppedSuccessfully = success // The error occors here: Cannot assign value of type '(Void) -> Void' to type '(() -> Void)?'
if WCSession.default.isReachable {
logger.info("Watch is reachable - Send Stop recording message.")
let command = RecordingCommand.stop
self.sendMessage(command, EvomoWatchConnectivityCore.WatchConnectivityCoreMethod.transferUserInfo,
nil, nil)
// Create a Timeout
let timeoutDelay: Double = 15
DispatchQueue.global().asyncAfter(deadline: DispatchTime.now() + timeoutDelay) {
if self.stoppedSuccessfully != nil {
self.logger.warning("### Stopped waiting for Apple Watch recording by Timeout!")
success(Void())
self.stoppedSuccessfully = nil
}
}
return
}
success(Void())
self.stoppedSuccessfully = nil
}
}
// In a other part of the code:
self.stoppedSuccessfully?()
self.stoppedSuccessfully = nil