dafi
2/23/2012 - 7:04 AM

Category to get the string description for a NSComparisonPredicate

Category to get the string description for a NSComparisonPredicate

//
//  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
//
//  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