I've looked all over and people say that using whereKey: equalTo:
will work in an array but for some reason it doesn't for me. I'm trying to have users search for a tag and all post that contain that tag appear. when I remove whereKey: equalTo:
I get all results but with it I get nothing. Any help would be greatly appreciated. Here is the code that takes care of creating and querying the class.
我看了一遍,人们说使用whereKey:equalTo:将在数组中工作但由于某种原因它不适合我。我正在尝试让用户搜索标记,并显示包含该标记的所有帖子。当我删除whereKey:equalTo:我得到了所有结果但是我得到了什么。任何帮助将不胜感激。以下是负责创建和查询类的代码。
import Foundation
class WallPost: PFObject, PFSubclassing {
@NSManaged var post: String
@NSManaged var user: PFUser
@NSManaged var tags: [String]
init(post: String, user: PFUser, tags: [String]) {
super.init()
self.post = post
self.user = user
self.tags = tags
}
override init() {
super.init()
}
override class func query() -> PFQuery?{
let query = PFQuery(className: parseClassName())
query.includeKey("user")
query.whereKey("tags", equalTo: "rock")
query.orderByDescending("createdAt")
return query
}
class func parseClassName() -> String {
return "POST"
}
override class func initialize(){
var onceToken: dispatch_once_t = 0
dispatch_once(&onceToken) {
self.registerSubclass()
}
}
}
I've added a screenshot of the parse class here
我在这里添加了解析类的截图
1 个解决方案
#1
0
If "tags" is the name of the array in parse, then you need to add this parameter to your query:
如果“tags”是解析中数组的名称,则需要将此参数添加到查询中:
query.whereKey("rock", containedIn: "tags")
#1
0
If "tags" is the name of the array in parse, then you need to add this parameter to your query:
如果“tags”是解析中数组的名称,则需要将此参数添加到查询中:
query.whereKey("rock", containedIn: "tags")