Created
May 9, 2014 15:56
-
-
Save pr8x/66b6a52bf77f1f9126bd to your computer and use it in GitHub Desktop.
NSObject+Predicate
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
#import <Foundation/Foundation.h> | |
@interface NSObject (Predicate) | |
/* applies predicate on single object and returns result */ | |
-(BOOL)meetsPredicate:(NSPredicate*)predicate; | |
@end |
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
#import "NSObject+Predicate.h" | |
@implementation NSObject (Predicate) | |
-(BOOL)meetsPredicate:(NSPredicate *)predicate { | |
NSArray* single = @[self]; | |
return [[single filteredArrayUsingPredicate:predicate] count] > 0; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful when it comes to evaluating objects and check if they meet certain conditions.
Cheers