开发者

NSString compare:options:range: - which value to pass for no options?

开发者 https://www.devze.com 2023-04-02 01:08 出处:网络
I want to call [NSString compare:options:range:] and pass no options. What should be the correct value to prov开发者_JAVA技巧ide for the options parameter?

I want to call [NSString compare:options:range:] and pass no options.

What should be the correct value to prov开发者_JAVA技巧ide for the options parameter?

Both nil and NULL produce a warning in Xcode : "Incompatible pointer to integer conversion sending 'void *' to parameter of type ... "


Just pass 0. Alternatively, if you've been around the Mac block a few times, you might catch yourself passing kNilOptions which is just another name for 0, but implies the relevant flagginess.


You should pass 0. The options argument is a bit mask, which really means it's just an integer. That's also why the warning says "integer conversion".


As Apple Docs says:

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.

NSCaseInsensitiveSearch : A case-insensitive search.

NSLiteralSearch : Exact character-by-character equivalence.

NSNumericSearch : Numbers within strings are compared using numeric value, that is, Name2.txt < Name7.txt < Name25.txt.

String Programming Guide

0

精彩评论

暂无评论...
验证码 换一张
取 消