Skip to content

Instantly share code, notes, and snippets.

@dafi
Created February 23, 2012 07:04
Show Gist options
  • Save dafi/1891221 to your computer and use it in GitHub Desktop.
Save dafi/1891221 to your computer and use it in GitHub Desktop.
Category to get the string description for a NSComparisonPredicate
//
// 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
//
// 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