不区分大小写的NSString比较

问题描述:

使用此代码我可以比较字符串值。

Using this code I am able to compare string values.

[elementName isEqualToString: @"Response"]

但这种情况下比较敏感。有没有办法比较不区分大小写的字符串?

But this compares case-sensitively. Is there a way to compare the string without case sensitivity?

有一个 caseInsensitiveCompare:方法 NSString ,为什么不读文档?该方法返回 NSComparisonResult

There’s a caseInsensitiveCompare: method on NSString, why don’t you read the documentation? The method returns NSComparisonResult:

enum {
   NSOrderedAscending = -1,
   NSOrderedSame,
   NSOrderedDescending
};
typedef NSInteger NSComparisonResult;

...啊,对不起,刚才我意识到你要求区分大小写>平等。 (为什么我不读这个问题?:-)默认 isEqual: isEqualToString:区分大小写,是什么给了?

…ah, sorry, just now I realized you are asking for case sensitive equality. (Why don’t I read the question? :-) The default isEqual: or isEqualToString: equality should already be case sensitive, what gives?