• 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: Uli Kusterer <email@hidden>
  • Date: Tue, 18 Jan 2011 05:58:06 +0100

On 17.01.2011, at 19:50, Quincey Morris wrote:
> 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.

 Which is good to know if you want to use NSNotFound in your own classes, but largely irrelevant if it is an index into a collection of objects, like NSArray. Because in that case, just storing the pointers to these items in an array (which takes 4 bytes in 32-bit, 8 in 64-bit) already restricts the number of items to a value below NSIntegerMax.

 After all, you'd already run out of address space around NSIntegerMax / 2 (NSUIntegerMax / sizeof(id), i.e. NSUIntegerMax / 4). And since you need memory for system libraries, and for the NSArray and stored object(s) itself (it could be an array containing the same object over and over, though), plus a stack and general memory management overhead, you'll lose a few bytes more.

 Considering Apple's frameworks change size with each system release, I don't think there is a way to reliably calculate an upper limit. If your application is likely to even vaguely get near the ballpark of NSIntegerMax / 2, you should probably look into implementing a virtual memory-like mechanism that swaps in/out objects from disk as needed.

-- Uli Kusterer
Sole Janitor
http://www.the-void-software.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: NSNotFound
      • From: Matt Gough <email@hidden>
References: 
 >NSNotFound (From: Richard Somers <email@hidden>)
 >Re: NSNotFound (From: Thomas Davie <email@hidden>)
 >Re: NSNotFound (From: "Sean McBride" <email@hidden>)
 >Re: NSNotFound (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: How to change the product name with command line builds?
  • Next by Date: Anybody have problems with plist settings not getting into or being honored by phone app?
  • Previous by thread: Re: NSNotFound
  • Next by thread: Re: NSNotFound
  • Index(es):
    • Date
    • Thread