I am trying to query my _User
class for a specific objectId, and download an image from it.
The objectId
passed through the userList
is the correct one, if checked against the parse.com user table.
The array returned is always empty
Any help would be appreciated.
func imageArrayFromUserList(userList: [PFUser]) -> [UIImage] {
var arrayToReturn: [UIImage] = []
for user in userList {
let objectID = user.objectId
let query = PFUser.query()
//let query = PFQuery(className: "_User")
query!.whereKey("objectId", equalTo: objectID!)
//query?.limit = 1
query!.findObjectsInBackgroundWithBlock({ (results: [AnyObject]?, error: NSError?) -> Void in
if error != nil{// This never prints anything to console
println(error)
}
if let results = results as? [PFObject] {
for object in results {
let userPicture = object["image"] as! PFFile
userPicture.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
if error == nil {
if let imageData = imageData {
let image = UIImage(data:imageData)
arrayToReturn.append(image!)
}
}
}
}
}
})
}
return arrayToReturn
}//end of imageArrayFromUserList method