iosswiftuiimagepffile

Converting PFFile to UIImage


What are the steps to convert the PFFile to UIImage

I managed to get the image from parse as PFFile. But I can't show the view to the user since its not an UIImage.

Can anyone guide me please?

I keep getting

 error: [UIImageView setFile:]: unrecognized selector sent to instance 0x7ff2937a9bd0 on the console

Whenever I tried to get image file from parse and set it to UIImage

Here's the code for setting the file to UIImageView

var initialThumbnail = UIImage(named: "AppIcon")
        cell.customImage.image = initialThumbnail
        if let picture = object?["image"] as? PFFile {
            cell.customImage.file = picture
            cell.customImage.loadInBackground()
        }

Here's the code for the customImage outlet

@IBOutlet weak var customImage: PFImageView!

Other data loads just fine, but the only problem is file data.


Solution

  • I am doubtful that the class of the ImageView is UIImageView and not PFImageView...

    Select your imageView and go to identity inspector, it must be appearing like this...

    Must be this currently...

    Should be this...

    Should be like this...

    As it is PFImageView that understands the getter and setter methods for property 'file'.