如何在 Parse 上取回用户的数据? [英] How can I get back data of user on Parse?
问题描述
我想在 Parse.t 上的User"中的requestActive"中取回数据
I want to get back data in "requestActive" in "User" on Parse.t
我试试这个:
var user = PFUser()
var requestActive = user["requestActive"]
但是:错误实例成员 'user' 不能用于类型 'viewController'
but : error "instance member 'user' cannot be used on type 'viewController'
推荐答案
您正在视图控制器的顶层声明 user
.
You are declaring user
at the top level of your view controller.
但是,仍然在根级别,您尝试将它与 user["requestActive"]
一起使用:您不能这样做.
But then, still at the root level, you try to use it with user["requestActive"]
: you can't do that.
您必须在方法中使用 user
,例如 viewDidLoad
.
You have to use user
in a method, for example viewDidLoad
.
所以假设 user["requestActive"]
的类型是一个字符串(仅作为示例),您可以执行以下操作:
So let's say the type of user["requestActive"]
would be a String (just for the example), you would do something like:
var user = PFUser()
var requestActive: String?
override func viewDidLoad() {
super.viewDidLoad()
requestActive = user["requestActive"]
}
当然,您必须将 String 替换为您的实际类型.
Of course, you have to replace String with your actual type.
这篇关于如何在 Parse 上取回用户的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!