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

标签 ios xcode swift ios8

<分区>

我没有足够的声誉来发布图片, 我正在使用 Parse 进行注册,它显示“PFUser”没有名为“subscript”的成员错误

请检查下面的代码

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

关于ios - 'PFUser' 没有名为 'subscript' 的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32689453/

相关文章:

ios - 如何获取用户当前位置和其他一些坐标是否相同?

objective-c - 分配的对象的潜在泄漏 - 不知道为什么

ios - 生成未签名的 IPA iOS 应用程序

iphone - 如何获取最近 7 天的绝对数据,而不是 SQLite iPhone 中的最近 7 条记录

swift - UIView 子类 (Swift4) - 自定义方法 (setNumber) 未按预期工作

ios - 切换 UIKeyboardTypeNamePhonePad 默认 View

xcode - ./configure 未被识别为 cmdlet 的名称

swift - 在 CoreML(.mlmodel 文件)中出现错误?

swift - Swift 有并发安全保证吗?

ios - 如何一次在屏幕上显示多个 UITableViewController?我的 table 只是显示为空白