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 protected])

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

This email sent to [EMAIL PROTECTED]

Reply via email to