【问题标题】:Unicode formatting compiler warning: Format specifies type 'unsigned short' but the argument has type 'int'Unicode 格式化编译器警告:格式指定类型“无符号短”,但参数的类型为“int”
【发布时间】:2012-08-06 00:43:11
【问题描述】:

这有点强迫症,但我讨厌收到任何编译器警告。当我更新 XCode 时,我开始收到这个编译器警告:

格式指定类型“无符号短”,但参数的类型为“int”

当我尝试使用以下代码包含学位的 Unicode 字符时:

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

如何通过更改代码或关闭特定的编译器警告来消除编译器警告?

【问题讨论】:

    标签: objective-c ios xcode unicode nsstring


    【解决方案1】:

    将文字转换为unichar:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-12
      • 1970-01-01
      • 2012-03-10
      • 2014-04-23
      • 1970-01-01
      • 2013-01-31
      • 1970-01-01
      相关资源
      最近更新 更多