gpt4 book ai didi

swift - Parse 和 Swift 上的关系查询

转载 作者:行者123 更新时间:2023-11-30 10:12:17 25 4
gpt4 key购买 nike

我正在尝试获取与类相关的对象。

以下是我的查询:

var user = PFUser.currentUser()
println("PERSON\(user)")
var relation = user!.relationForKey("followingThings")
var queryTeste = relation.query()
queryTeste?.findObjectsInBackgroundWithBlock({ (object: [AnyObject]?, error: NSError?) -> Void in
println("OBJECTS FROM RELATIONAL QUERY\(object)")
})

如果您查看输出,我可以检索我的关系对象,但是...我在检索它们之前收到错误。

我尝试了不同的组合来摆脱它,但没有成功。此外,这里的大多数问题都是关于 Objective C 和 sintaxe 的,方法也略有不同。

关于可能导致错误的原因有什么想法吗?

PERSONOptional( { email = "myemail@gmail.com"; emailVerified = 1; followingThings = " Things>"; points = 10; username = Me; })

2015-08-31 19:16:32.161 App[30479:9376080] [Error]: field followingThings cannot be included because it is not a pointer to another object (Code: 102, Version: 1.8.0)

OBJECTS FROM RELATIONAL QUERYOptional([

Things: 0x7ff031a736c0, objectId: G29f9Wfqj5, localId: (null)> { description = Camping; searchKey = camping; usersFollowing = " _User>"; },

Things: 0x7ff031a76520, objectId: IPEg4G2Qec, localId: (null)> { description = "Animal Care"; searchKey = "animal care"; usersFollowing = " _User>"; },

Things: 0x7ff031a76120, objectId: Jg4oRjebKE, localId: (null)> { description = Bicycling; searchKey = bycicling; usersFollowing = " _User>"; },

Things: 0x7ff031a75810, objectId: TseQvlo6AL, localId: (null)> { description = Boating; searchKey = boating; usersFollowing = " _User>"; }])

最佳答案

对我来说就是这样

    var relation = currentUser.relationForKey("product")
relation.query()?.findObjectsInBackgroundWithBlock({

(let productResult, let error) -> Void in
//println("result:\(productResult!.count)")

if let result = productResult {
//println(result.count)
for product in result {
println(product)
}
}
}

关于swift - Parse 和 Swift 上的关系查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32306031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com