0

Hi I am getting this error when I implement this code Cannot convert value of type 'URL' to expected argument type 'String' I know what it means but is there a way I can change the code below to work?

var userProfile: UserProfile?{

    didSet{

        let url = URL(string: (userProfile?.photoURL)!)

        if let url = url as? URL{


            KingfisherManager.shared.retrieveImage(with: url as Resource) { (image, error, cache, imageURL) in
                           self.profileImage.image = image
                           self.profileImage.kf.indicatorType = .activity
                       }

        }



    }
}
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441

1 Answers1

0

Here’s the solution:

var userProfile: UserProfile?{
    didSet{


        if let url = userProfile?.photoURL {


            KingfisherManager.shared.retrieveImage(with: url as Resource) { (image, error, cache, imageURL) in
                           self.profileImage.image = image
                           self.profileImage.kf.indicatorType = .activity
                       }

        }



    }
}
qBen_Plays
  • 262
  • 2
  • 9