获取PFUser对象自定义值 [英] Get PFUser object custom values

查看:106
本文介绍了获取PFUser对象自定义值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在名为"website"的PFUser列中有自定义值.我正在尝试使用下面的代码获取此值,但是如果我使用数据查看器从其网站上的Parse.com更新该值,则该值在设备上似乎没有改变.它也不会在设备之间更新. 有任何想法吗?

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

推荐答案

我已经设法使其与下面的代码一起使用.

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

这篇关于获取PFUser对象自定义值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆