On 20 Jul 2013, at 23:06, Matt Neuburg <m...@tidbits.com> wrote:

> On iOS, NSNotFound is defined as NSIntegerMax. However, the index of an 
> NSArray, which is a case where you'd often want to use NSNotFound (e.g. 
> indexOfObject:), is of type NSUInteger.
> 
> Isn't there a type mismatch here? It seems to me that NSNotFound ought to be 
> a value *outside* the possible range NSArray index values - which it would 
> be, if NSNotFound were NSUIntegerMax, or if NSArray's indexes were of type 
> NSInteger. As thing are, when you call indexOfObject: and test the result 
> against NSNotFound, you could be getting the wrong answer; if that index 
> happens to be NSIntegerMax (which is only halfway through the available 
> unsigned indexes), it will seem to be NSNotFound when in fact it is an actual 
> index.
> 
> I must be wrong about this, since Apple wouldn't make such a basic mistake. 
> So what's *my* mistake? Thx - m.

Quite simply, there isn't enough memory available in the address space to ever 
create a useful array containing NSIntegerMax number of objects.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to