Re: NSUInteger question
Re: NSUInteger question
- Subject: Re: NSUInteger question
- From: "Michael Ash" <email@hidden>
- Date: Wed, 9 Apr 2008 12:39:27 -0400
On Wed, Apr 9, 2008 at 12:30 PM, Corbin Dunn <email@hidden> 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.
> >
>
> I think everyone is missing the point. The advantage is not "None".
>
> Chris Parker already gave the first good advantage. The second is this: Use
> NSInteger/NSUInteger everywhere in your app. Recompile it for 64-bit and you
> instantly have a fully 64-bit version with very little work. That's a huge
> advantage.
But the same effect could be had simply by using "long" and "unsigned
long". If those are not well defined enough for you then you can use
the types in stdint.h or sys/types.h so that you can pick a type which
means exactly what you want. For example, if you're worried about
future compatibility on an LLP64 system, intptr_t and uintptr_t are
essentially equivalent to NS[U]Integer in meaning.
My understanding is that the main advantage of NS[U]Integer is that
it's still an int, not a long, on 32-bit. While the two types are
essentially identical in the 32-bit world, they do have different
@encode strings, so using NS[U]Integer avoids changing the signatures
of methods which existed prior to 10.5.
IMO it's dangerous to talk about a 64-bit conversion in this manner.
Much like any other architecture change, there are a lot of different
effects and blindly using "safe" types is not guaranteed to make your
app work after a recompile. Likewise an application which uses
non-NSInteger types may be written to Just Work when recompiled as
64-bit.
Mike
_______________________________________________
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