Get PFUser object custom values

一笑奈何 提交于 2020-01-06 13:55:16

问题


I have custom value in a PFUser column called "website". I am trying to get this value using the code below but it does not seem to change on the device if I update the value from Parse.com on their website using the data viewer. It also does not update across devices. Any Ideas?

websiteField.text = currentUser.objectForKey("website") as String


回答1:


I have managed to get it working with the code below.

var currentUser = PFUser.currentUser()
    currentUser.refreshInBackgroundWithBlock { (object, error) -> Void in
        println("Refreshed")
        currentUser.fetchIfNeededInBackgroundWithBlock { (result, error) -> Void in

            self.websiteStr = currentUser.objectForKey("website") as String
            self.websiteField.text = self.websiteStr

            println("Updated")

            println(self.websiteStr)
        }
    }


来源:https://stackoverflow.com/questions/27284575/get-pfuser-object-custom-values

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