NSUInteger - unsigned long or unsigned int?
Hi,
I am doing most of my iOS code in AppCode these days (thank you again JetBrains for this wonderful, intelligent editor and debugger), but as I work on a project with some xib-files and a CoreData model, I have to dive into Xcode frequently. I have just noticed that if I have code like this:
NSUInteger hg2g = 42;
NSLog(@"The answer is: %d", hg2g);
AppCode says: "Format specifier '%d' requires the type 'int' instead of 'NSUInteger'..."
Then I fix it by changing it to:
NSUInteger hg2g = 42;
NSLog(@"The answer is: %lu", hg2g);
Then I go into Xcode which says: "Conversion specifies type 'unsigned long' but the argument has type 'NSUInteger' (aka 'unsigned int')
Fix-it in Xcode "repairs" it to:
NSUInteger hg2g = 42;
NSLog(@"The answer is: %u", hg2g);
And now AppCode of course says: "Format specifier '%u' requires the type 'unsigned int' instead of 'NSUInteger'..."
Which is right?
NSUInteger is defined in the "NSObjCRuntime.h" file:
#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 typedef long NSInteger; typedef unsigned long NSUInteger; #else typedef int NSInteger; typedef unsigned int NSUInteger; #endif
请先登录再写评论。
Filed an issue:
http://youtrack.jetbrains.net/issue/OC-941