So I have been trying to retrieve an image from Parse since yesterday and I am very confused. I read similar questions and examples but all of them were people saving some image first, then retrieving it. What I want to do is simply retrieve an image that I manually uploaded to parse, I have been trying with this:
//Retrieving image from parse
var object = PFObject(className:"ClassImage")
let getParseImg = object["image"] as! PFFile
getParseImg.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
if (error == nil){
if let imageData = imageData{
println("Retrieving Image")
let img = UIImage(data:imageData)
self.imageView.image = img
}
}
}
In line two, it throws a "unexpectedly found nil while unwrapping an Optional value", I already tried "if let getParseImg", then it throws another error, in the end the line ended up looking like this:
if let getParseImg = object["image"] as? PFFile{
So after that, everything goes fine and compiles but it doesn't do absolutely anything, it does not get and display the image and it doesn't even print "Retrieving Image", any ideas how can I solve this, I am new to Parse so still getting familiarized with it.
Thanks in advance!