NSInteger precedence = [self operatorPrecedence];
[d appendFormat:@"precedence:%d, ", precedence];
gives:
Warning: Format specifies type 'int' but the argument has type 'NSInteger' (aka 'long')
and Xcode suggests to change %d
to %ld
.
However, it only works for either 32-bit or 64-bit target, as NSInteger
is:
#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
What's the best way to kill the warning, for both 32-bit and 64-bit targets?
Follow the instructions in Apple's 64-Bit Transition Guide.
For an NSInteger
, use %ld
and cast the value to long
.
[d appendFormat:@"precedence:%ld, ", (long)precedence];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With