NSLog giving me warnings which are not correctable

cocoa, format-specifiers, nslog, xcode

Solution

Yeah this is annoying. It is a 32/64 bit thing I believe. The easiest thing to do is just cast to a long:

NSLog(@"number of items: %lu", (unsigned long)[urlArray count]);

Problem

I have the following line of code in my Mac OS X application: ``` NSLog(@"number of items: %ld", [urlArray count]); ``` And I get the warning: "Format specifies type 'long' but the argument has type 'NSUInteger' (aka 'unsigned int')" However, if I change my code to: ``` NSLog(@"number of items: %u", [urlArray count]); ``` I get the warning: Format specifies type 'unsigned int' but the argument has type 'NSUInteger' (aka 'unsigned long') So then I change it to ``` NSLog(@"number of items: %u", [urlArray count]); ``` but I get the warning: Format specifies type 'unsigned long' but the argument has type 'NSUInteger' (aka 'unsigned int') How can I set up my NSLog so it does not generate a warning? If I follow Xcode's suggestions i just get into in an endless loop of changing the format specifier but the warnings never go away.

Original source

Related problems