PFUser does not have a member named subscript?

泄露秘密 提交于 2019-12-02 18:09:31

问题


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... }

回答1:


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... }



回答2:


If you are using iOS 9 you must download the new parse SDK, thats why you are having that problem.



来源:https://stackoverflow.com/questions/32620466/pfuser-does-not-have-a-member-named-subscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!