• 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: NSUInteger question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUInteger question


  • Subject: Re: NSUInteger question
  • From: Chris Parker <email@hidden>
  • Date: Wed, 9 Apr 2008 09:17:36 -0700


On 8 Apr 2008, at 6:19 PM, Christopher Nebel wrote:
On Apr 8, 2008, at 5:30 PM, Timothy Reaves wrote:

What advantage does NSUinteger have over uint32? I realize that on a 64 bit machine, it would be a uint64.

"Advantage"? None, really. It's a question of what you're trying to express -- do you want specifically a 32-bit unsigned integer, or do you want an unsigned integer that reflects the architecture's word size? For instance, there's no particular reason to limit NSArray's capacity to exactly 2^32 items all the time, so -count is defined as returning an NSUInteger -- 2^32 in 32-bit, or 2^64 in 64- bit. (Also consider the analogous size_t type.)

Well, that and this:

The advantage is not having to do something like this:

	#if __LP64__
	- (int)someMethodWhichTakes:(int)foo;
	#else
	- (int64_t)someMethodWhichTakes:(int64_t)foo;
	#endif

and sprinkle those all over the place later too...

This:

	- (NSInteger)someMethodWhichTakes:(NSInteger)foo;

is far more readable. :)

.chris

_______________________________________________

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


References: 
 >NSUInteger question (From: Timothy Reaves <email@hidden>)
 >Re: NSUInteger question (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: some questions about creating image thumbnails
  • Next by Date: Re: some questions about creating image thumbnails
  • Previous by thread: Re: NSUInteger question
  • Next by thread: Re: NSUInteger question
  • Index(es):
    • Date
    • Thread