ios - 从解析中检索数据并在 viewController 中使用它

标签 ios swift parse-platform pfquery

这就是我如何使用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 中出现错误..知道我哪里错了吗?感谢您抽出时间。

最佳答案

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

关于ios - 从解析中检索数据并在 viewController 中使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32221842/

相关文章:

ios - 如何测试用 DispatchQueue.main.async 调用的方法?

ios - 运行 MPMoviePlayerController 时崩溃

Xcode 7.1 与 iOS 9.1 错误 : include of non-modular header inside framework module 'Parse.PFGeoPoint'

arrays - 将任何对象作为参数的 Swift 数组的扩展函数

javascript - 解析: Retrieving properties from an object that is related

ios - 按下后退按钮时 PFQueryTable ViewController 重新加载表

iphone - 第二次尝试时,viewDidAppear 在 CellForRowAtIndex 之后加载

android - JWPlayer 无法在 iPhone 和 iPod 中运行

arrays - 有没有更好的方法在 Swift textView 中对齐这列数字?

ios - 清理项目 "Command builtin-rm failed with exit code 513"找到