compare: options: range:
Returns the result of invoking
compare:options:range:locale: with a nil locale.
- (NSComparisonResult)compare:(NSString *)aString options:(NSStringCompareOptions)mask range:(NSRange)range
Parameters of [NSString compare options range]
- aString
- The string with which to compare the range of the receiver specified by range.This value must not be
nil. If this value isnil, the behavior is undefined and may change in future versions of OS X. - mask
- Options for the search—you can combine any of the following using a C bitwise OR operator:
NSCaseInsensitiveSearch,NSLiteralSearch,NSNumericSearch.See String Programming Guide for details on these options. - range
- The range of the receiver over which to perform the comparison. The range must not exceed the bounds of the receiver.
Return Value of [NSString compare options range]
The result of invoking
compare:options:range:locale: with a nil locale.Discussion
If you are comparing strings to present to the end-user, you should typically use
compare:options:range:locale:instead and pass the user’s locale (currentLocale [NSLocale]).Example of [NSString compare options range]
if([txtAnswer.text compare:answer options:NSCaseInsensitiveSearch] == NSOrderedSame)
{
// Do somehing
}
Example of [NSString compare options range]
NSComparisonResult result = [selectedString compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];