"关闭不能隐含地捕获变异的自我参数" - 更新到Swift 3之后

时间:2017-03-01 18:52:55

标签: swift swift3

我有一个在后台线程中使用self的代码。它运行得非常好,直到我将它迁移到Swift 3,从那时起我每次使用self时都会得到一条错误消息:&#34; Closure不能隐式捕获变异的自身参数&#34;。< / p>

我的代码是这样的:

mutating func fetchData() {  
    DispatchQueue.global(qos: .background).async {
        for className in self.classNames {
            let query = PFQuery(className: className)
            query.limit = 1000

            do {
                for obj in try query.findObjects() {
                    let typeObj = TypeObj(parseObject: obj, typeName: className)

                    if className == “type1”{
                        self.type1s.append(store)
                    } else if className == “type2” {
                        self.type2s.append(store)
                    } else if className == “type3” {
                        self.type3s.append(store)
                    } else if className == “type4” {
                        self.type4s.append(store)
                    } else if className == “type5” {
                        self.type5s.append(store)
                    }
                }
            }
            catch _ {
               // Error handling
            }
        }

        let dict = [
                “Type1s”:self.type1s,”Type2s”:self.type2s,”Type3s”:self.type3s,”Type4s”:self.type4s,”Type5s”:self.type5s
        ]
        self.delegate.getDictionary(dict)
    }
}

0 个答案:

没有答案