I'm trying to load an image stored in a Firebase server. I was checking other answers but I couldn't find why I'm getting a nil after being able to print the right String value:
In my application I have the following data structure:
And here the code I'm using to load it (The nil value is the one shown on the comment)
let profileDetailsRef = self.ref.childByAppendingPath("users/" + sessionUserID + "/details")
profileDetailsRef.observeEventType(.Value, withBlock: { snapshot in
self.txtUsername.text = sessionUserID
self.txtDisplayName.text = snapshot.value.objectForKey("nameToDisplay") as? String
let base64EncodedString = snapshot.value.objectForKey("userImage")! as! String
print(base64EncodedString) //Here it's printing well because I get the same value as shows in the dasboard so it finds it
//But the value "decodedData" here below is returning **nil**
let decodedData = NSData(base64EncodedString: base64EncodedString as! String, options: NSDataBase64DecodingOptions())
let decodedImage = UIImage(data: decodedData!)!
self.imageUserImage.image = decodedImage
}, withCancelBlock: { error in
print(error.description)
})
Thanks!
