【问题标题】:Data retrieved from parse and use it in a viewController从 parse 中检索的数据并在 viewController 中使用它
【发布时间】:2015-08-26 08:42:14
【问题描述】:

这就是我使用objectId 检索用户信息的方式:

func loadData() {

    userId = toPass

    data.removeAllObjects()

    var profileQuery:PFQuery = PFUser.query()!
        profileQuery.whereKey("objectId", equalTo: userId)
        profileQuery.getObjectInBackgroundWithId(userId, block: { (objects, error) -> Void in
            if error == nil {
                self.data.addObject(objects!)
                println(self.data)  //...shouldn't be empty here
            } else {
                println("Error retrieving user: \(error) ")   
            }  
        })
   }


 override func viewDidLoad() {
    super.viewDidLoad()

    loadData()
   fullName.text = self.data["fullName"] as! String! // ***** error here.. cannot assign a value of type 'String' to a value of type 'String?'

}

viewDidLoad 中有错误。知道我哪里错了吗?感谢您的宝贵时间。

【问题讨论】:

    标签: ios swift parse-platform pfquery


    【解决方案1】:

    data 是一个 parseobjects 数组,您想从中读取 parseobject 属性...遍历数组或从中获取特定的索引号,然后从中加载“fullname”属性或使用 getFirstObject... 方法

    【讨论】:

    • 我该怎么做?我是这里的初学者。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-05
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多