On Feb 2, 2016, at 11:45 , Jens Alfke <j...@mooseyard.com> wrote:
> 
> (To be clear: I understand why this behaves differently, due to the [awful] 
> decision to make NSInteger different sizes in 32-bit vs 64-bit. But at a high 
> level it’s an inconsistent warning, when you have multiple platforms to build 
> for.)

As suggested by Greg Parker on this list a couple of years ago, you can use

        %t… (%td, %to, %tu %tx, %tX) for unsigned results
        %z… (%zd, %zo, %zu %zx, %zX) for signed results

and these work on NS[U]Integer-sized variables on all platforms and 
architectures that are supported by Apple (without having to cast the 
parameters).

The ’t’ or ‘z’ controls whether the conversion is unsigned or signed. The ‘d’ 
or ‘u’ controls whether the parameter is an signed or unsigned variable. This 
is kinda a distinction without a difference, so, normally, it’s %tu for 
NSUInteger, and %zd for NSInteger.

These modifiers are documented here:

        
https://developer.apple.com/library/prerelease/watchos/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html

but using them for this purpose is a trick that is (AFAIK) Greg’s own 
brain-storm.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (Xcode-users@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to