Reputation: 933
Function produces expected type '(() -> ())?'; did you mean to call it with '()'?
I am getting the above error. Auto fix from Xcode does not help.
The error is on self.performOnCommunicationQueue()
:
func getAuthParams(authClosure:((error:NSError?) -> ())?) {
logDebug("Starting sync session with Max device")
if let statusError = self.assertReady() {
logError("Start sync session failed with error: \(statusError)")
if (authClosure != nil) {
authClosure!(error: statusError)
}
} else {
self.performOnCommunicationQueue() {
let error:NSError?
// Set random starting byte
let oAbsTime:[UInt64] = [mach_absolute_time()]
let payload:NSData = NSData(bytes: oAbsTime, length: 8)
let absTime:UInt8 = UnsafePointer<UInt8>(payload.bytes).memory
self.randomCryptoByte = (0x01 | ( absTime & 0xfe))
}
}
func sendAuthChallenge(authChal:String, completion:((error:NSError?) -> ())?) {
}
func performOnCommunicationQueue(closure:(()->())?){
if (closure != nil)
{
self.communicationQueue?.addOperationWithBlock(closure!)
}
}
Upvotes: 0
Views: 1789
Reputation: 1926
I think this is what you want:
self.performOnCommunicationQueue({ () -> () in
let error:NSError?
// Set random starting byte
let oAbsTime:[UInt64] = [mach_absolute_time()]
let payload:NSData = NSData(bytes: oAbsTime, length: 8)
let absTime:UInt8 = UnsafePointer<UInt8>(payload.bytes).memory
self.randomCryptoByte = (0x01 | ( absTime & 0xfe))
})
This creates the void to void closure that performOnCommunicationQueue
requires.
Also, check that your braces match up once you've made this change, I think you might be one short, which is why autocomplete wasn't a help.
Upvotes: 5