I'm trying to append images retrieved from parse database, but nothing is being added to the UIImage array. How do I append the retrieved images?
var arrayOfFriends: [UIImage] = []
func getFriendPic(){
var imagequery = PFQuery(className: "_User")
imagequery.findObjectsInBackgroundWithBlock {( objects: [AnyObject]?, error: NSError?) -> Void in
for object in objects!{
let userPic = object["ProPic"] as! PFFile
userPic.getDataInBackgroundWithBlock({ (imageData: NSData?, error: NSError?) -> Void in
if(error == nil){
let image = UIImage(data: imageData!)
//breakpoint placed on line below, but app crashes with array out of bounds.
self.arrayOfFriends.append(image!)
print(self.arrayOfFriends)
}
dispatch_async(dispatch_get_main_queue()) {
self.collectionView.reloadData()
}
})
}
}
}