gpt4 book ai didi

ios - 解析 findObjectsInBackgroundWithBlock 错误部分不起作用

转载 作者:搜寻专家 更新时间:2023-11-01 05:39:44 24 4
gpt4 key购买 nike

在我的解析表中有列。位置和国家。如果是真的,数据将加载到应用程序中。但问题是,它永远不会参与findObjectsInBackgroundWithBlockwherekeys都错了。总是打印出 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
}
}

关于ios - 解析 findObjectsInBackgroundWithBlock 错误部分不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32045396/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com