Created
February 23, 2012 07:04
-
-
Save dafi/1891221 to your computer and use it in GitHub Desktop.
Category to get the string description for a NSComparisonPredicate
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
// | |
// NSComparisonPredicate+HumanDescriptions.h | |
// VisualDiffer | |
// | |
// Created by davide ficano on 13/02/12. | |
// Copyright (c) 2012 visualdiffer.com. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSComparisonPredicate (HumanDescriptions) | |
- (NSString*)humanDescription; | |
@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
// | |
// NSComparisonPredicate+HumanDescriptions.m | |
// VisualDiffer | |
// | |
// Created by davide ficano on 13/02/12. | |
// Copyright (c) 2012 visualdiffer.com. All rights reserved. | |
// | |
#import "NSComparisonPredicate+HumanDescriptions.h" | |
@implementation NSComparisonPredicate (HumanDescriptions) | |
- (NSString*)humanDescription { | |
switch ([self predicateOperatorType]) { | |
case NSLessThanPredicateOperatorType: | |
return @"Is Less Than"; | |
case NSLessThanOrEqualToPredicateOperatorType: | |
return @"Is Less Than Or Equal"; | |
case NSGreaterThanPredicateOperatorType: | |
return @"Is Greater Than"; | |
case NSGreaterThanOrEqualToPredicateOperatorType: | |
return @"Is Greater Than Or Equal"; | |
case NSEqualToPredicateOperatorType: | |
return @"Is"; | |
case NSNotEqualToPredicateOperatorType: | |
return @"Is Not Equal To"; | |
case NSMatchesPredicateOperatorType: | |
return @"Matches"; | |
case NSLikePredicateOperatorType: | |
return @"Is Like"; | |
case NSBeginsWithPredicateOperatorType: | |
return @"Begins With"; | |
case NSEndsWithPredicateOperatorType: | |
return @"Ends With"; | |
case NSInPredicateOperatorType: | |
return @"In"; | |
case NSCustomSelectorPredicateOperatorType: | |
return @"Custom Selector"; | |
case NSContainsPredicateOperatorType: | |
return @"Contains"; | |
case NSBetweenPredicateOperatorType: | |
return @"Between"; | |
} | |
return @"Invalid"; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment