• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Something strange in the NSString documentation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Something strange in the NSString documentation


  • Subject: Something strange in the NSString documentation
  • From: Stephane Sudre <email@hidden>
  • Date: Fri, 19 Aug 2005 13:17:17 +0200

The documentation for the [NSString hasSuffix:] method is:

"
- (BOOL)hasSuffix:(NSString *)aString

Returns YES if aString matches the ending characters of the receiver, NO otherwise. Returns NO if aString is the nil string or empty. This method is a convenience for comparing strings using the NSAnchoredSearch and NSBackwardsSearch options. See “Strings” for more information.
See Also: – hasPrefix:, – compare:options:range:
"


The strange point is the link to -compare:options:range:.

The way I understand how the compare:options:range method is working "compared" to the rangeOfString;options: API and the way the documentation is presenting things, I would tend to believe that the link shall be to the -rangeOfString;options: instead.

For instance, if I want to check if a string has a suffix with an insensitive case search, the shortest code (with the smallest number of arguments) could look like this:

- (BOOL) hasCaseInsensitiveSuffix:(NSString *) inSuffix
{
NSRange tRange;

tRange=[self rangeOfString: inSuffix options: NSCaseInsensitiveSearch+NSBackwardsSearch+NSAnchoredSearch];

return (tRange.location!=NSNotFound)
}


It could be argued that you can do exactly the same things with -compare:options:range: but then I'm wondering why the documentation is referring to NSAnchoredSearch since this option does not seem to make sense with the compare: methods.

Am I missing something?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Something strange in the NSString documentation
      • From: Jack Nutting <email@hidden>
  • Prev by Date: Re: Newbie: help with NSTableView and NSPopUpButtonCell
  • Next by Date: Re: screen savers
  • Previous by thread: Controlling brightness and contrast of monitor
  • Next by thread: Re: Something strange in the NSString documentation
  • Index(es):
    • Date
    • Thread