NSNotFound signed???
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