在我的應用程序中,當用戶註冊時,他/她註冊,圖像被添加到用戶類中。用於執行此操作的代碼是...如何從用戶類分析中提取文件swift
var newUser = PFUser()
let imageData = UIImagePNGRepresentation(self.imageView.image)
let imageFile = PFFile(data: imageData)
newUser.setObject(imageFile, forKey: "image")
newUser.signUpInBackgroundWithBlock({
(success, error) -> Void in
})
後來在我的應用程序中,我想將該圖片放入UIImageView中。我試圖做到這一點的方式是這樣的。
var user = PFUser.currentUser() //Error on this line
let profileImage = user["image"] as! PFFile
但是,這會返回錯誤「AnyObject?不能轉換爲PFFile」。我想知道如何使用用戶類中的關鍵字「image」檢索文件。謝謝你的幫助。
PFFile線上的錯誤?或者在用戶= PFUser.currentUser()行? – Jbryson
PFUser.currentUser()行@Jbryson –