Swift 3.0 Error: Escaping closures can only capture inout parameters explicitly by value

后端 未结 3 1129
遇见更好的自我
遇见更好的自我 2020-11-29 22:54

I\'m trying to update my project to Swift 3.0 but I have some difficulties. I\'m getting next error: \"Escaping closures can only capture inout parameters explicitly by valu

3条回答
  •  孤街浪徒
    2020-11-29 23:38

    If you are sure that your variable will be available the whole time just use a true Pointer (same what inout actually does)

    func foo(val: UnsafeMutablePointer, completion: @escaping (NSDictionary) -> Void) {
        val.pointee = NSDictionary()
        DispatchQueue.main.async {
            completion(val.pointee)
        }
    }
    

提交回复
热议问题