ericg
ericg

Reputation: 8722

What NSString compare method call is equivalent to a CFStringCompare function call?

I am converting some old carbon code to Cocoa and need to use a comparison function that will return the same result as the one in carbon.

I am calling:

CFStringCompare( stringA, stringB, kCFCompareCaseInsensitive | kCFCompareDiacriticInsensitive | kCFCompareNumerically );

Now, if stringA & stringB were NSString's and I wanted to compare them using a NSString method, which one, with what options (if any), would return the same result as the CFStringCompare function above?

Upvotes: 0

Views: 926

Answers (2)

ericg
ericg

Reputation: 8722

The answer appears to be:

NSStringCompareOptions  compareOptions = NSCaseInsensitiveSearch | NSNumericSearch | NSDiacriticInsensitiveSearch;

result = [stringA compare:stringB options:compareOptions];

Upvotes: 3

Antwan van Houdt
Antwan van Houdt

Reputation: 6991

[string1 isEqualToString:string2];

[string1 caseSensitiveCompare:string2];

and so on.

goto the NSString class reference for more information

Upvotes: -1

Related Questions