• 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: NSNotFound
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNotFound


  • Subject: Re: NSNotFound
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 17 Jan 2011 10:50:58 -0800

On Jan 17, 2011, at 08:28, Sean McBride wrote:

> On Sat, 15 Jan 2011 18:51:52 +0000, Thomas Davie said:
>
>> NSNotFound could have *any* value, and in fact its value could change
>> from cocoa version to cocoa version.  Stop looking!
>
> If they change it, they'll break binary compatibility with existing
> apps.  So it won't be changing.  (Which isn't a reason to bypass it, but...)

Some further musings on this subject:

Yes, in one sense the actual value should be irrelevant, but in fact when NSNotFound is a possible value of a scalar that's truly numeric (such as a count or an index) you really *do* need to know what NSNotFound is. For example, you have to be careful not to increment a numeric quantity into NSNotFound.

In this kind of situation (e.g. the documentation says "returns a NSUInteger value representing the index of the matching item, or NSNotFound if no match is found") the usable value range is really 0 .. NSNotFound-1. That imposes a practical limit on the number of items, which the developer needs to know.

In a slightly larger, conceptual sense, this means that unless you want to obsess over the specifics of *every* frameworks parameter *every* time you use one, the *practical*, everyday-use range of NSUInteger is 0 .. NSIntegerMax, not 0 .. NSUIntegerMax. In 32-bit, that's a 2 Gig item limit, not 4 Gigs.

FWIW


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSNotFound
      • From: Uli Kusterer <email@hidden>
    • Re: NSNotFound
      • From: Richard Somers <email@hidden>
References: 
 >NSNotFound (From: Richard Somers <email@hidden>)
 >Re: NSNotFound (From: Thomas Davie <email@hidden>)
 >Re: NSNotFound (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: Why can't a modal view controller present another in viewDidLoad?
  • Next by Date: Re: Question about split view
  • Previous by thread: Re: NSNotFound
  • Next by thread: Re: NSNotFound
  • Index(es):
    • Date
    • Thread