Re: NSUInteger in for-loop?
Re: NSUInteger in for-loop?
- Subject: Re: NSUInteger in for-loop?
- From: Jason Coco <email@hidden>
- Date: Mon, 15 Sep 2008 00:49:51 -0400
On Sep 15, 2008, at 00:44 , Alex Reynolds wrote:
The %lu with casting seems to run into the same issue as %u:
...
2008-09-14 21:43:07.241 NSUIntTest[19779:10b] NSUInteger: 2
2008-09-14 21:43:07.259 NSUIntTest[19779:10b] NSUInteger: 1
2008-09-14 21:43:07.260 NSUIntTest[19779:10b] NSUInteger: 0
2008-09-14 21:43:07.261 NSUIntTest[19779:10b] NSUInteger: 4294967295
2008-09-14 21:43:07.262 NSUIntTest[19779:10b] NSUInteger: 4294967294
...
Interesting.
It does this because your building a 32-bit app. The NSUInteger will
change size in a 64-bit app which is why using %lu and typecasting to
(unsigned long) is recommended (this will ensure that you don't get
warnings if you build a 64-bit app from the same code). Too
demonstrate, recompile your app as such:
gcc -o <myapp> myapp.m -arch x86_64 -framework Foundation
(this assumes an Intel processor... if you're using a PPC then use
ppc64 instead of x86_64 for the arch).
Jason
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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