How to convert an PFFile to an UIImage with swift?

后端 未结 3 1542
难免孤独
难免孤独 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:58

    Swift 1.2+ Version

            if let userPicture = PFUser.currentUser()!.valueForKey("Image") as? PFFile {
                userPicture.getDataInBackgroundWithBlock {
                    (imageData: NSData?, error: NSError?) -> Void in
    
                    if error == nil {
                        let image = UIImage(data:imageData!)
                        self.ImageArray.append(image)
                    }else{
                        print("Error: \(error)")
                    }
                }
            }
    

提交回复
热议问题