Last active
August 29, 2015 14:19
-
-
Save Koze/8b974a35da71d63f81b0 to your computer and use it in GitHub Desktop.
NSPredicate with UTI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testImageUTI | |
{ | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF UTI-CONFORMS-TO %@", (__bridge NSString *)kUTTypeImage]; | |
NSLog(@"%@", predicate); | |
// SELF UTI-CONFORMS-TO "public.image" | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeJPEG]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypePNG]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeGIF]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeMPEG4]); | |
// 0 | |
} | |
- (void)testAudioUTI | |
{ | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF UTI-CONFORMS-TO %@", (__bridge NSString *)kUTTypeAudio]; | |
NSLog(@"%@", predicate); | |
// SELF UTI-CONFORMS-TO "public.audio" | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeMP3]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeMPEG4Audio]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeWaveformAudio]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeMPEG4]); | |
// 0 | |
} | |
- (void)testEqualsUTI | |
{ | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF UTI-EQUALS %@", (__bridge NSString *)kUTTypeJPEG]; | |
NSLog(@"%@", predicate); | |
// SELF UTI-EQUALS "public.jpeg" | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypeJPEG]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:(__bridge NSString *)kUTTypePNG]); | |
// 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment