gpt4 book ai didi

ios - 解析查询 .whereKey

转载 作者:行者123 更新时间:2023-11-30 14:08:41 24 4
gpt4 key购买 nike

这是我的代码:

 func loadData() {

data.removeAllObjects()
isLiking.removeAll(keepCapacity: true)
likes.removeAll(keepCapacity: true)

var followedUserQuery:PFQuery = PFQuery(className: "Followers")
followedUserQuery.whereKey("follower", equalTo: PFUser.currentUser()!.objectId!)

followedUserQuery.findObjectsInBackgroundWithBlock { (objects, error) -> Void in

if let objects = objects {

for object in objects {

var followedUser = object["user"] as! String


println(followedUser)

var postQuery:PFQuery = PFQuery(className: "Posts")
var postQuery:PFQuery = PFQuery(className: "Posts")
postQuery.whereKey("postedBy", equalTo: followedUser || PFUser.currentUser()!.objectId!) // cannot invoke 'whereKey' with an argument list of type '(String, equalTo: Bool)'

postQuery.orderByDescending("createdAt")
postQuery.findObjectsInBackgroundWithBlock ({ (objects, error) -> Void in

if let objects = objects {

for object in objects {

if let post = object as? PFObject {

self.data.addObject(object)

我在代码中收到上面注释的错误。我想从 Posts 类中检索 posts ,该类将由关注的用户发布并由当前用户发布。我怎样才能做到这一点?我也尝试过这个:

  var postQuery:PFQuery = PFQuery(className: "Posts")
postQuery.whereKey("postedBy", equalTo: followedUser)
postQuery.whereKey("postedBy", equalTo: PFUser.currentUser()!.objectId!)

通过使用这个我只获取当前用户的帖子。

但这确实有效。有没有其他方法可以获取关注用户和当前用户发布的帖子?我愿意接受任何类型的建议。

最佳答案

这行代码的语法错误:

postQuery.whereKey("postedBy", equalTo: followedUser || PFUser.currentUser()!.objectId!)

您的第二个参数是一个 bool 条件,您正在尝试将其与字符串进行比较。创建“followedUser”和“PFUser.currentUser()!.objectId!”的字符串数组并使用“whereKey:containedIn:”函数,而不是“whereKey:equalTo””

关于ios - 解析查询 .whereKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32023763/

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