Icloud查询结果出现EXC_BAD_INSTRUCTION错误

时间:2016-03-11 21:19:14

标签: swift cloudkit

为了尝试学习一些CloudKit基础知识,我正在构建一个应用程序,允许用户发布问题并接收" Up Vote"或"向下投票"。应用程序运行正常,直到我添加一个条目然后重新加载。当我尝试将向上或向下值添加到数组时,为什么会收到错误EXC_BAD_INSTRUCTION(code = EXC_1386_INVOP,subcode = 0x0)?

        self.pred = NSPredicate(format: "TRUEPREDICATE")
        let query = CKQuery(recordType: "Questions", predicate: NSPredicate(value: true))
        self.queryOperation = CKQueryOperation (query: query)
        self.queryOperation.recordFetchedBlock = {
            record in

            self.recArray.append(record.objectForKey("Question") as! String)
            self.recIdArray.append(record.recordID)

            //Gives me the correct value
            print(record.objectForKey("Up") as! Int64)

            //Errors on these 2 lines
            self.upArray.append(record.objectForKey("Up") as! Int64)
            self.downArray.append(record.objectForKey("Down") as! Int64)

        }

1 个答案:

答案 0 :(得分:0)

我通过更改数组的声明来修复它:     var upArray = Int64     var downArray = Int64 至:     var upArray = AnyObject     var downArray = AnyObject

希望这也有助于其他人