我有一个名称数组和一个字符串类型的列,我正在尝试获取信息。当我对 where 键中的每个值使用 for 循环时,我得到很多相同的信息,所以说有 5 个名字,我试图获取速率(一个整数)我会得到 100 个值而不是只需 5 个。
var name = ["Dog", "Cat", "Monkey"]
let query = PFQuery(className: "Animals")
query.whereKey(not sure what to put since it is an array)
query.findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) in
if(error == nil){
for object in objects!{
if let rating = object["rate"] as? Int{
self.rater.append(rating)
print("rating \(self.rater)") //There are like 75-100 values
}
}
}else{
print(error)
}
}
最佳答案
我不太了解Parse,但是有这个方法-whereKey:containedIn:
它需要一个数组。那对你不起作用吗? (抱歉,我没有找到 Swift 文档)
文档说:
-whereKey:containedIn:
Add a constraint to the query that requires a particular key’s object to be contained in the provided array.
Declaration OBJECTIVE-C
- (nonnull instancetype)whereKey:(nonnull NSString *)key containedIn:(nonnull NSArray *)array;
Parameters:
-
key
The key to be constrained.-
array
The possible values for the key’s object.
关于ios - 如何在字符串列中使用 where 键数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36799985/