'PFUser'没有名为'subscript'的成员



我没有足够的声誉来发布这些图片,我正在使用Parse注册,它显示我'PFUser'没有一个名为'下标'的成员错误

请检查下面的代码

var user = PFUser()
    user.username = usernameTextField.text
    user.email = emailTextField.text
    user.password = passwordTextField.text
    let imageData = UIImagePNGRepresentation(self.profileImage.image)
    let imageFile = PFFile(name: "profilePhoto.png", data: imageData)
    user["photo"] = imageFile -> [error in this line]

    user.signUpInBackgroundWithBlock { (succeeded, error) -> Void in
        if error == nil {
            println("Signup Successful")
        }
        else {
            println("Signup Failed")
        }

    }

这意味着您不能使用下标访问属性image。用user.photo

代替user["photo"]

我知道了!

        user.setValue(imageFile, forKey:"photo")

它现在工作了!!

最新更新