【发布时间】:2016-06-16 03:05:03
【问题描述】:
我尝试过使用其他解决方案,但没有成功。我需要将数据保存到 UIImages 数组中,因此在创建单元格时,它只需从已制作的图像数组中分配图像。问题是它返回零。我还需要确保图像是有序的。
/--UPDATING YOUR POSTS AFTER YOU POSTED--\\
func updatePosts(){
if Reachability.isConnectedToNetwork() {
self.images.removeAll(keepCapacity: true)
let query = PFQuery(className: "Shoes")
query.whereKey("createdBy", equalTo: PFUser.currentUser()!.username!)
query.orderByDescending("createdAt")
query.limit = 1000
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
print("Successfully retrieved \(objects!.count) scores.")
for object in objects! {
let imageFile = (object["imageFile"] as! PFFile)
imageFile.getDataInBackgroundWithBlock{
(imageData: NSData?, error: NSError?) -> Void in
if error == nil {
let image = UIImage(data: imageData!)
self.images.append(image!)
}
}
self.ids.append(object.objectId as String!)
}
dispatch_async(dispatch_get_main_queue(), {
self.collectionView.reloadData()
})
}
else {
print(error)
}
}
} else {
print("Internet connection not available")
// This is Depreciated!!
let alert = UIAlertView(title: "No Internet connection", message: "Please ensure you are connected to the Internet", delegate: nil, cancelButtonTitle: "OK")
alert.show()
}
}
【问题讨论】:
标签: ios arrays swift parse-platform