-
-
Save defragged/cd1649edbf7934a37e17 to your computer and use it in GitHub Desktop.
Method to do case insensitive string comparisons, working around the method returning `YES` if the receiver is `nil`.
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> | |
/** Methods to help with determining string equality */ | |
@interface NSString (Equality) | |
/** | |
* Returns `YES` if the receiving string is equal to the | |
* argument, ignoring case. | |
* | |
* So `latex` will be equal to `LaTeX` for instance. | |
* | |
* @param string The string to compare with | |
* @return `YES` if the strings are equal. `NO` otherwise. | |
*/ | |
- (BOOL)isEqualIgnoringCase:(NSString *)string; | |
@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 "NSString+Equality.h" | |
@implementation NSString (Equality) | |
- (BOOL)isEqualIgnoringCase:(NSString *)string { | |
return [self caseInsensitiveCompare:string] == NSOrderedSame; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment