1
我想做一个搜索功能,查询来自同一类的两个不同的键。我可以使用哪种正则表达式返回最准确的值。例如:搜索功能解析IOS
- (void)searchTableList {
[self.results removeAllObjects];
PFQuery *query = [PFQuery queryWithClassName:@"TC"];
CLLocationCoordinate2D coordinate = [self.delegate.location coordinate];
PFGeoPoint *geoPoint = [PFGeoPoint geoPointWithLatitude:coordinate.latitude
longitude:coordinate.longitude];
PFQuery *query1 = [PFQuery queryWithClassName:@"TC"];
[query1 setLimit:1000];
[query1 whereKey:@"location"
nearGeoPoint:geoPoint
withinKilometers:5];
[query1 whereKey:@"courses" matchesRegex:[NSString stringWithFormat:@"%@",[self.searchBar.text lowercaseString]]];
[query1 whereKey:@"owner" notEqualTo:[PFUser currentUser].username];
[query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
for(PFObject * object in objects)
{
[self.results addObject:object];
}
[query setLimit:1000];
[query whereKey:@"location"
nearGeoPoint:geoPoint
withinKilometers:5];
[query whereKey:@"owner" matchesRegex:[NSString stringWithFormat:@"%@",[self.searchBar.text lowercaseString]]];
[query whereKey:@"owner" notEqualTo:[PFUser currentUser].username];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
for(PFObject * object in objects)
{
[self.results addObject:object];
}
[self.tableView reloadData];
}];
}];
}
我该如何处理这两个查询并按照最精确的信息优先的方式进行排序。