我目前正在同时执行两个PFQueries,一个是PFUser.query
,另一个是标准对象查询。这些都试图大致同时执行。我在代码中没有错误,直到它运行它说:
'Cannot do a comparison query for type: Swift._NSSwiftArrayImpl'
我只能假设这是因为我试图一次做两个不同的查询?
有人可以添加一些输入意味着什么意思更多以及如何克服它?
我用于两个查询的代码是:
var query = PFQuery(className: "Traits")
query.whereKey("name", equalTo: self.names)
var waveUsers = query.findObjects()
if waveUsers != nil {
self.profile.waves.removeAll(keepCapacity: true)
for waveUser in waveUsers{
self.profile.waves.append(waveUser["waves"] as Int)
}
}
和PFUser查询:
var query = PFUser.query()
query.whereKey("location", nearGeoPoint:geopoint)
query.limit = 20
var users = query.findObjects()
if users != nil {
self.profile.names.removeAll(keepCapacity: true)
self.profile.images.removeAll(keepCapacity: true)
self.profile.genders.removeAll(keepCapacity: true)
self.profile.locations.removeAll(keepCapacity: true)
self.profile.status.removeAll(keepCapacity: true)
self.profile.rStatus.removeAll(keepCapacity: true)
self.profile.age.removeAll(keepCapacity: true)
for user in users {
{
self.profile.names.append(user["name"] as Int)
self.profile.images.append(user["image"] as NSData)
self.profile.genders.append(user["gender"] as NSString)
self.profile.locations.append(user["location"] as PFGeoPoint)
self.profile.rStatus.append(user["relationship"] as NSString)
self.profile.age.append(user["age"] as NSInteger)
self.profile.status.append(user["status"] as NSString)
self.appsTableView.reloadData()
user.save()
}
}
提前致谢
答案 0 :(得分:0)
如果您想测试是否可以在self.names
数组中找到“名称”列,请使用containsAllObjectsInArray:
equalTo
对单个对象进行操作(它可以测试单个对象在数组类型列中的存在,但是您正在尝试相反的方式)。
编辑 - 假设您有一个字符串数组,并且您希望找到在数组中找到字符串列的对象...
// find people in the People class who were SNL cast members
var array = ["belushi", "akroyd", "radner"];
var queries = [];
// assume underscorejs
_.each(array, function(name) {
var query = new Parse.Query("People");
query.equalTo("lastName", name);
queries.push(query.find());
});
Parse.Query.or(queries).then(function() {
var snlCastMembers = _.toArray(arguments);
});