Skip to content

Commit

Permalink
Merge pull request #956 from eddielee6/master
Browse files Browse the repository at this point in the history
Fixed issue where search did not take into account the users preference for game names.
  • Loading branch information
cyco committed Dec 31, 2013
2 parents 153fb71 + 0503fd4 commit 442d434
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion OpenEmu/OECollectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,20 @@ - (void)viewDidAppear
#pragma mark Toolbar Actions
- (IBAction)search:(id)sender
{
NSPredicate *pred = [[sender stringValue] isEqualToString:@""]?nil:[NSPredicate predicateWithFormat:@"name contains[cd] %@", [sender stringValue]];
NSString *searchTerm = [sender stringValue];
NSArray *tokens = [searchTerm componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

NSMutableArray *predarray = [NSMutableArray array];
for(NSString *token in tokens)
{
if(token.length > 0)
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"displayName contains[cd] %@", token];
[predarray addObject:predicate];
}
}
NSPredicate *pred = [NSCompoundPredicate andPredicateWithSubpredicates:predarray];

[gamesController setFilterPredicate:pred];

[listView reloadData];
Expand Down

0 comments on commit 442d434

Please sign in to comment.