Search code examples
iosswiftparse-platformpfuser

PFUser does not have a member named subscript?


I am using Parse's PFUser to create and save a user's information when they sign up but I'm getting an error "'PFUser' does not have a member named 'subscript'" at the lines where I have to set the user's firstName and zipcode. The code ran perfectly before and I haven't been able to find anything online or in my history that would explain this error. Please help!

 func signUp() {
    var user                            = PFUser()
    user.email                          = email.text
    user["firstName"]                   = firstName.text
    user["zipcode"]                     = zipcode.text
    user.objectId = objectId
//etc... }

Solution

  • You can use the method setValue:forKey:

    Example:

    func signUp() {
        var user = PFUser()
        user.email = email.text
        user.setValue(firstName.text, forKey:"firstName")
        user.setValue(zipcode.text, forKey:"zipcode")
        user.objectId = objectId
    //etc... }