swift - 使用指针解析检索 PFObject

标签 swift pointers parse-platform pfquery

我有两个类 Place 和 BeenHere。 BeenHere 具有名为“toPlace”和“fromUser”的指针,相应地指向 Class Place 和 User。 Place 依次具有我想要检索并显示在 ViewController 中的标题和图像 (PFFile)。在下面的代码中,我已经到达了带有 objectId 的指针,但不知道现在如何检索与该指针指向的特定位置相关的标题和图像。感谢您的帮助和建议。

class UserBeenHereViewController: UIViewController {       
override func viewDidLoad() {
    super.viewDidLoad()

    let user = PFUser.currentUser()?.username

    if user != nil {

    let query = PFQuery(className: "BeenHere")
            query.includeKey("toPlace")
            query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
        if error == nil {
            for object in objects! {
                print(object["toPlace"].objectId)

            }
        }
            else {
                print("There is error")
            }
        }
    }
}

最佳答案

首先,您需要将“toPlace”放入一个 PFObject 中,然后访问它。所以在你的情况下它应该看起来像:

var toPlace = comment["toPlace"] as? PFObject
print (toPlace["title"])

关于swift - 使用指针解析检索 PFObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38676925/

相关文章:

c# - float* 从 C 到 C#

ios - 数据服务错误未解决

ios - 使用 UIActivityViewController 在非官方 Twitter 客户端上共享内容?

swift - 只能通过使用最终类来满足的 Swift 协议(protocol)要求

amazon-web-services - AWS Bitnami 解析服务器 - 添加 HTTP 身份验证使我的应用程序在解析仪表板 'unauthorized'

ios - 解析使用指针两次

date - Parse.com — 在 Swift 中使用日期对象进行查询

swift - 如何使用 Swift 查询 Firebase 的特定值

使用不同的堆栈指针调用 C 函数 (gcc)

c++ - 指针算术编译失败,gcc 说类型转换无效