代码下方是从parse.com检索。代码工作正常但不按顺序查询我的数据。有人可以解释原因吗?
func loadData(){
let findDataParse = PFQuery(className: "JobListing")
findDataParse.whereKey("user", equalTo: PFUser.currentUser()!)
findDataParse.orderByAscending("createdAt")
findDataParse.findObjectsInBackgroundWithBlock{
(objects: [PFObject]?, error: NSError?) -> Void in
if (error == nil) {
for object in objects! {
let userImageFile = object["ImageOne"] as! PFFile
let userImageFile1 = object["ImageTwo"] as! PFFile
let userImageFile2 = object["ImageThree"] as! PFFile
userImageFile.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
let listingImage1 = UIImage(data:imageData!)
userImageFile1.getDataInBackgroundWithBlock {
(imageData1: NSData?, error1: NSError?) -> Void in
let listingImage2 = UIImage(data:imageData1!)
userImageFile2.getDataInBackgroundWithBlock {
(imageData2: NSData?, error1: NSError?) -> Void in
let listingImage3 = UIImage(data:imageData2!)
let offers = Information(objectIDParam: object.objectId!, titleOfProjectParam: object["TitleOfProject"] as! String, categoryParam: object["Category"] as! String, viewsParam: object["Views"] as! String, image1Param: listingImage1!, image2Param: listingImage2!, image3Param: listingImage3!)
self.arrayOfOffers.append(offers)
for interests in object["InterestsArray"] as! NSArray{
self.arrayOfInterests.append(interests as! String)
}
self.i++
self.tableView.reloadData()
}}}}}}}
答案 0 :(得分:0)
这就是我要做的事情:
mutableArray
request
后,将其object
添加到mutableArray
并检查mutableArray.count == numberOfRequests
mutableArray
这会更快+更容易理解正在发生的事情。