Cog/Spotlight/NSComparisonPredicate+CogPredicate.m
Christopher Snowhill 85c7073649 Reformat my own source code with clang-format
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-06 21:49:27 -08:00

32 lines
No EOL
1 KiB
Objective-C

//
// NSComparisonPredicate+CogPredicate.m
// Cog
//
// Created by Matthew Grinshpun on 14/02/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "NSComparisonPredicate+CogPredicate.h"
// Ignore case and diacritics
static const unsigned OPTIONS = (NSCaseInsensitivePredicateOption |
NSDiacriticInsensitivePredicateOption);
@implementation NSComparisonPredicate (CogPredicate)
+ (NSPredicate *)predicateForMdKey:(NSString *)key
withString:(NSString *)aString
exactString:(BOOL)exactString {
// We don't want an exact string, so wrap it in wildcards
if(!exactString)
aString = [NSString stringWithFormat:@"*%@*", aString];
return [NSComparisonPredicate
predicateWithLeftExpression:[NSExpression expressionForKeyPath:key]
rightExpression:[NSExpression expressionForConstantValue:aString]
modifier:NSDirectPredicateModifier
type:NSLikePredicateOperatorType
options:OPTIONS];
}
@end