这是我的代码:
basic_auth
错误发生在let profileImage:PFFile = user [“profileImage”]行。它不会因为用户而构建。帮助赞赏!
答案 0 :(得分:0)
我认为它可能适合你。
@IBAction func setPicture(sender: UIButton) {
var imagePicker: UIImagePickerController = UIImagePickerController()
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.delegate = self
//getting the current user
var user = PFUser.currentUser();
let profileImage: PFFile = user["profileImage"] as! PFFile
profileImage.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
if error == nil {
let image: UIImage = UIImage(data: imageData!)!
self.profileImageView.image = image
}
}
self.presentViewController(imagePicker, animated: true, completion: nil)
}