解析查询返回无结果

时间:2015-09-23 09:41:30

标签: xcode swift parse-platform

在具有600k行的Parse数据库上运行查询。我想要的对象就在那里,但它仍然没有返回任何东西。一切都工作了几个星期然后随机停止。有任何想法吗?这是查询:

// make query on parse database to find code the person entered
                    let query: PFQuery = PFQuery(className: "code")
                    query.whereKey("code", containsString: self.codeInput.text!.uppercaseString)
                    query.findObjectsInBackgroundWithBlock {(objects: [AnyObject]?, error: NSError?) -> Void in

                    // store results
                    let results: NSArray = (array: objects!)

                    // Log the error if there is one
                    if (error != nil) {
                        self.wrongCodeAnimation()
                        print("error " + error!.localizedDescription)
                    }

                        // if there aren't any results, do wrong code animation
                    else if(results.count == 0){
                        print("nothing")
                        print(results)
                        self.wrongCodeAnimation()
                    }

                        // If no error, get array of results and validate the code, get the actual code for that object, and the valid state so we can pass them into the validate function
                    else {
                        let object: PFObject = results.objectAtIndex(0) as! PFObject
                        let code: String = object.objectForKey("code") as! String
                        let codeValid: Bool = object.objectForKey("valid") as! Bool
                        print(codeValid)
                        print(code)
                        self.validateCode(code, codeValid: codeValid, codeObject: object)
                    }

                }

1 个答案:

答案 0 :(得分:0)

显然正在改变

query.whereKey("code", containsString: self.codeInput.text!.uppercaseString)

query.whereKey("code", equalTo: self.codeInput.text!.uppercaseString)

正在做这个伎俩。任何人都知道为什么这会产生任何影响?