override func viewDidLoad() {
super.viewDidLoad()
let request = SFRestAPI.sharedInstance().requestForQuery("SELECT Name,Id FROM Account where parentid='\(self.accountId)'");
SFRestAPI.sharedInstance().sendRESTRequest(request, failBlock: {error in print(error)}, completeBlock: { responce in print(responce)
self.dataRows = responce["records"] as! [NSDictionary]
var counter = 0;
for i in self.dataRows
{
let requestForGrandChilds = SFRestAPI.sharedInstance().requestForQuery("select Name,Id from Account where parentid='\(i["Id"]!)'")
SFRestAPI.sharedInstance().sendRESTRequest(requestForGrandChilds,
failBlock:
{
error in print(error)
print("error block")
},
completeBlock:
{
responceChild in
self.grandChilds = responceChild["records"] as! [NSDictionary]
self.dataOfGrandChilds["\(counter)"] = self.grandChilds
print("id of parent \(i["Id"]!) and counter \(counter) and data \(self.dataOfGrandChilds["\(counter)"])")
//print(self.dataOfGrandChilds)
counter += 1
dispatch_async(dispatch_get_main_queue(),
{
print("Control came to main queue")
self.tableView.reloadData()
})
print("getting to know\(self.dataOfGrandChilds)")
})
}
})
}
在第一个请求中,我尝试获取一个 ID 的直接子帐户。在第一个请求的完成 block 中,我正在尝试获取 grand child accounts 。 dataRows 有部分标题的数据(这是直接的子名称)。 dataOfGrandChilds 是以节号为键,对应的 grandChilds 数组为值的字典。
当我把断点放在:
- 行号 10.SFRestAPI.sharedInstance().sendRESTRequest(requestForGrandChilds,
- 行号 23.counter += 1
dataOfGrandChilds 字典中的数据设置正确,当删除断点并执行时,dataOfGrandschilds 中的数据设置不当(即像其他一些键一样,其他一些值正在设置)
请帮帮我。
最佳答案
在 viewDidLoad()
中从您的数据库中获取完整数据,并将其放入[NSDictionary]
类型
然后编写搜索的代码
关于ios - 我无法正确收集响应。当我设置断点时它工作正常但没有断点它没有给出正确的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37676817/