I am working on an app using Parse as backend. Whenever I try to load an image the NSData that I get is not empty but whenever I try converting it to an UIImage the image I get is nil.
I already checked all the images on Parse and I can see/get all of them from the database. I also re-uploaded the images just in case something was wrong with them.
Here is the piece of code I get the NSData and convert it to UIImage:
let myImage = object.objectForKey("imagem") as! PFFile
myImage.getDataInBackgroundWithBlock({(imageData : NSData?, error : NSError?) -> Void in
if error == nil {
if let imageData = imageData{
if let newImage = UIImage(data: imageData){
myClass.imagem = newImage
}
}
}
self.collectionView?.reloadData()
})
It turns out the way I was doing was correct, but I was working through a proxy and whenever the data was being sent to my app it was not returning the full NSData. So the problem lies within the proxy and not the code. Thanks for the replies.