zoukankan      html  css  js  c++  java
  • [BS-15] Values of type 'NSInteger' should not be used as format arguments

    Values of type 'NSInteger' should not be used as format arguments

    苹果app支持arm64以后会有一个问题:NSInteger变成64位了,和原来的int (%d)不匹配,使用[NSString stringWithFormat:@“%d", integerNum]; 会报如下警告:

    Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead

    解决办法:

    1、系统推荐方法   [NSString stringWithFormat:@“%ld"(long)integerNum];

    2、强制转换int    [NSString stringWithFormat:@"%d"(int)integerNum];

    3、转为数字对象  [NSString stringWithFormat:@“%@", @(integerNum)];

    4、使用%zd占位符  [NSString stringWithFormat:@“%zd"integerNum];  (最简单的方法)

    补充:

    关于%zd格式化字符,只能运行在支持C99标准的编译器中,表示对应的数字是一个size_t类型,size_t是unsigned int 的增强版,表示与机器类型相关的unsigned类型,即:size-t在32位系统下是unsigned int(4个字节),在64位系统中为long unsigned int(8个字节)。

     

    C语言转义字符

         \ 反斜杠

      a 警告

       退格

      f 换页

       换行

       回车

       跳格Tab

      v 垂直跳格

          空格在输入时不需要转义,直接敲空格

     

     

    iOS开发者交流群:180080550
  • 相关阅读:
    HI3518+RTSP(转)
    Linux常用命令英文全称与中文解释(转)
    旋转编码器正反转检测
    shell文件操作大全(转)
    makefile文件操作大全(转)
    Linux文件操作高频使用命令(转)
    浅谈linux中的根文件系统(转)
    分压电阻采样问题(转)
    python实现邮件发送
    50个很棒的Python模块
  • 原文地址:https://www.cnblogs.com/stevenwuzheng/p/5470034.html
Copyright © 2011-2022 走看看