• 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
Re: Substring in String?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Substring in String?


  • Subject: Re: Substring in String?
  • From: Jim Correia <email@hidden>
  • Date: Sun, 17 Feb 2002 13:22:00 -0500

On Sunday, February 17, 2002, at 01:08 PM, Finlay Dobbie wrote:

On Sunday, February 17, 2002, at 05:26 PM, Ondra Cada wrote:

if ([s rangeOfString:ss].length) ...

Shouldn't that be

if ([s rangeOfString:ss].length != NSNotFound) ...

It is probably stylistically better to say

if ([s rangeOfString: ss] != NSNotFound)
{

}

However, the documentation states that the range {NSNotFound, 0} is returned if the string isn't found, so the first test would also be valid way to test for success.

NSNotFound should never be returned in the length field, so your test should never be a valid way to test for success.

Jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Substring in String?
      • From: Finlay Dobbie <email@hidden>
References: 
 >Re: Substring in String? (From: Finlay Dobbie <email@hidden>)

  • Prev by Date: Re: Substring in String?
  • Next by Date: Re: what's an NSZone?
  • Previous by thread: Re: Substring in String?
  • Next by thread: Re: Substring in String?
  • Index(es):
    • Date
    • Thread