解析配置文件图像麻烦

时间:2015-06-17 23:13:05

标签: ios xcode swift parse-platform

这是我的代码:

basic_auth

错误发生在let profileImage:PFFile = user [“profileImage”]行。它不会因为用户而构建。帮助赞赏!

1 个答案:

答案 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)
}