NSConfusedCoder
NSConfusedCoder

Reputation: 55

Unicode formatting compiler warning: Format specifies type 'unsigned short' but the argument has type 'int'

It's a tad OCD, but I hate getting any compiler warnings. When I updated XCode, I started getting this compiler warning:

Format specifies type 'unsigned short' but the argument has type 'int'

When I tried including the Unicode character for degree using the following code:

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

How do I make the compiler warning go away, either by changing the code or turning off that particular compiler warning?

Upvotes: 5

Views: 1732

Answers (1)

trojanfoe
trojanfoe

Reputation: 122401

Cast the literal to unichar:

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

Upvotes: 14

Related Questions