繁体   English   中英

解析findObjectsInBackgroundWithBlock错误部分不起作用

[英]Parse findObjectsInBackgroundWithBlock error part not working

在我的解析表中有列。 位置和国家。 如果是真的,数据将加载到应用程序。但是问题是,即使wherekeys错误,它也永远不会在findObjectsInBackgroundWithBlock其他部分。 始终打印出This section calling行。

 var findLiveFeedData:PFQuery = PFQuery(className: "Spreads")
        findLiveFeedData.whereKey("location", equalTo: city)
        findLiveFeedData.whereKey("country", equalTo: country)


        findLiveFeedData.findObjectsInBackgroundWithBlock{
            (objects:[AnyObject]?, error:NSError?)->Void in

            if error == nil{
                if let objects = objects as? [PFObject] {
                for object in objects{
                    self.LiveFeedData.addObject(object)
                    }
                }
                println("This section calling")
                let array:NSArray = self.LiveFeedData.reverseObjectEnumerator().allObjects
                self.LiveFeedData = NSMutableArray(array: array)

                self.tableView.reloadData()

            }else{
                println("Error") // This section never gets called

            }
        }

即使您使用错误的键进行查询,也不会返回错误,但它将返回包含0个条目的数组。 因此,找出是否仍未找到要使用的方法:

if objects != nil {
    if objects!.count > 0 {
        //You are safe to use the array
    } else {
        //Nothing was returned
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM