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

type of NSNotFound


  • Subject: type of NSNotFound
  • From: Matt Neuburg <email@hidden>
  • Date: Sat, 20 Jul 2013 15:06:14 -0700

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.

--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 6! http://shop.oreilly.com/product/0636920029717.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com


_______________________________________________

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: type of NSNotFound
      • From: Quincey Morris <email@hidden>
    • Re: type of NSNotFound
      • From: Uli Kusterer <email@hidden>
    • Re: type of NSNotFound
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: Threads
  • Next by Date: Re: type of NSNotFound
  • Previous by thread: Re: Breakpoint when NSString gets set to a certain value?
  • Next by thread: Re: type of NSNotFound
  • Index(es):
    • Date
    • Thread