I have previously been retrieving an image form my Parse backend to display in my app inside a UIImageView using the following lines of code:
let userPicture = PFUser.currentUser()["picture"] as PFFile
userPicture.getDataInBackgroundWithBlock { (imageData:NSData, error:NSError) -> Void in
if (error == nil) {
self.dpImage.image = UIImage(data:imageData)
}
}
But I get the error:
'AnyObject?' is not convertible to 'PFFile'; did you mean to use 'as!' to force downcast?
The 'helpful' Apple fix-it tip suggests the "as!" change so I add in the !, but then I get the error:
'AnyObject?' is not convertible to 'PFFile'
With the 'getDataInBackgroundWithBlock' section, I also get the error:
Cannot invoke 'getDataInBackgroundWithBlock' with an argument list of type '((NSData, NSError) -> Void)'
Can someone please explain how to correctly retrieve a photo from Parse and display it in a UIImageView using Swift 1.2?