How to convert an PFFile to an UIImage with swift?

后端 未结 3 1525
难免孤独
难免孤独 2020-12-04 00:43

How do i convert an PFFile to an UIImage with swift?

In this code, the app is getting the file from parse and now i want it to show on a UIImageView, But i get an er

3条回答
  •  有刺的猬
    2020-12-04 00:50

    With Swift 3 on Parse.

      if let photo = obj.file as? PFFile {
           photo.getDataInBackground(block: {
              PFDataResultBlock in
              if PFDataResultBlock.1 == nil {//PFDataResultBlock.1 is Error
                        if let image = UIImage(data:PFDataResultBlock.0!){
                            //PFDataResultBlock.0 is Data
                            photoCell.attachedPicture.image = image
                        }
    
                    }
                })
            }
    

提交回复
热议问题