Unicode formatting compiler warning: The format indicates the type is "unsigned short", but the argument is of type "int",

It's a bit of an OCD, but I hate getting compiler warnings. When I updated Xcode, I started getting a warning from this compiler:

The format indicates the type "unsigned short", but the argument is of type "int"

When I tried to include the Unicode character to get the degree, using the following code:

currentVal = [NSString stringWithFormat:@"%.2f%C", angleDeg, 0x00B0];

How do I get a compiler warning to go away, either by changing the code or by disabling this compiler warning?

+5
source share
1 answer

Pass the literal unichar:

currentVal = [NSString stringWithFormat:@"%.2f%C", angleDeg, (unichar)0x00B0];
+14
source

All Articles