1

please check my image for storing and retrieving dataenter image description here

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
   }


 }

    }
Akbar
  • 15
  • 10

1 Answers1

0

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)
Anand
  • 1,820
  • 2
  • 18
  • 25
  • I have already stored the image infact it is the Download ur,l if you see my model for user I put the url in my dictionary as the document stated , I think I am using story board may be that's why but still looking to resolve this issue. – Akbar Apr 18 '19 at 07:33
  • 1
    @Akbar You are just setting `imageUrl` in `User` model so you still have to download the image from this `URL`. Follow the question referenced above to download the image. – Kamran Apr 18 '19 at 07:55
  • @kamran I have attach an image above on how I am storing and retrieving image I have tried above code it didn't work. – Akbar Apr 18 '19 at 08:13
  • @Anand it didn't worked also can you fix my code review thanks – Akbar Apr 18 '19 at 08:16
  • @Anand ["userAge": 22, "userName": haren] https://firebasestorage.googleapis.com/v0/b/haay-84d3f.appspot.com/o/userPicture%2FBD41FDD0-85EE-479B-80D0-9E1F758A4ED9?alt=media&token=30097c65-f41a-4a26-97e0-1b2282ed3755 – Akbar Apr 18 '19 at 08:27
  • Permission denied. Not able to see the values in the above link. – Anand Apr 18 '19 at 08:27
  • @Anand sorry no idea you mind checking I am storing and retrieving picture code is right above I have attached a new picture.(code) above – Akbar Apr 18 '19 at 08:30