please check my image for storing and retrieving data
I am getting an error because I want retrieve image from firebase, my url is string but error states about uiImage cannot be string, is there away I can get an image shown of my uiImageView.
By the Way this is my model view class of user below class User {
var username:String!
var userage:String!
var uid:String!
var profileImageUrl: String!
init (uid:String,dictionary:Dictionary<String,AnyObject>) {
self.uid = uid
if let username = dictionary [ "userName" ] as? String{
self.username = username
}
if let userage = dictionary [ "useAge" ] as? String {
self.userage = userage
}
if let profileImageUrl = dictionary["profileImageUrl"] as? String
{
self.profileImageUrl = profileImageUrl
}
}
}
If user.profileImageURL
is actually an URL, you have to download the image and assign that to self.swipeLabel.image
.
To download image from URL, Please refer this post: Create a UIImage with a URL in iOS
If the image is already stored, the use the following code.
self.swipeLabel.image = UIImage(contentsOfFile: profileimageurl)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.