类型'() - >的表达没有更多的背景是模棱两可的

时间:2017-06-21 06:36:53

标签: swift swift3

enter image description here

let lockQueue = DispatchQueue(label: "com.test.LockQueue")
imapSession?.connectionLogger = { (UnsafeMutableRawPointer, MCOConnectionLogType, data) -> () in
    lockQueue.sync() {
        if (type != MCOConnectionLogType.SentPrivate) {  //error is coming in this line
            //TODO: better memory management
            if let data = data {
                let errorString = NSString(data: data, encoding: String.Encoding.utf8.rawValue)
                print("event logged \(String(describing: UnsafeMutableRawPointer)) withData: \(errorString!)")

我已经从swift 1.2转换为swift 3.2。我将dispatch_queue_create更改为最新语法,但最终面临此问题。任何人都可以建议我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您必须在闭包中传递值/变量而不是类型

   imapSession?.connectionLogger = { (pointer, type, data) in

除非编译器告诉你这样做,否则不要在Swift中使用NSString

let errorString = String(data: data, encoding: .utf8)