I am wondering if I have done anything wrong here.
I have a subclass of PFUser
which has a property of profileImage
, which is a PFFile
There are some cases when I don't save the profileImage
right away to Parse and I only pin it to the localDatastore
.
But when I tried to retrieve it back from the localDataStore
and use the getDataInBackgroundWithBlock
. It does not return any error, but the NSData returned by the callback is always nil.
if let profileImage = PGUser.currentUser()?.profileImage {
profileImage.getDataInBackgroundWithBlock { (data: NSData?, error: NSError?) -> Void in
if error == nil {
if data != nil {
println("IMAGE DATA FOUND")
let image = UIImage(data: data!);
self.profileImageView.image = image;
}
else {
//DATA IS ALWAYS NIL
println("NO IMAGE DATA FOUND")
}
}
}
}
- The
PGUser.currentUser()?.profileImage
is NOT NIL - No error returned by the
getDataInBackgroundWithBlock
function. - BUT the data is always NIL.
Any thoughts on what am I doing wrong?
Thank you!!
Try this. I solved my problem with this