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

NSNotFound signed???


  • Subject: NSNotFound signed???
  • From: Oleg Krupnov <email@hidden>
  • Date: Wed, 12 Jun 2013 10:11:27 +0300

I've just been shocked to find out that NSNotFound is defined by the
framework as NSIntegerMax, that is maximal value of *SIGNED* integer,
which in 64 bit architecture is 0x7fffffffffffffff.

I used to think that it should be NSUIntegerMax, that is the maximal
value of *UNSIGNED* integer, corresponding to 0xffffffffffffffff.

It had to be so because NSNotFound value is used in many places of the
system framework for working with array indexes, for example,
-[NSArray indexOfObject:] returns unsigned NSUInteger indexes, *BUT*
it returns NSNotFound if the element is not found.

But NSNotFound should be a valid index in the middle of possible
unsigned integer range! It means that even though the NSArray allows
NSUIntegerMax of elements, you can actually use only NSIntegerMax
elements, because starting from NSIntegerMax you will get screwed up
by things like indexOfObject:

How come?
_______________________________________________

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 signed???
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Staying on integrated GPU while using NSOpenGLView
  • Next by Date: Re: NSNotFound signed???
  • Previous by thread: Re: Character encoding of C-string runtime functions?
  • Next by thread: Re: NSNotFound signed???
  • Index(es):
    • Date
    • Thread