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
  • 相关阅读:
    设计模式之桥接模式
    设计模式之适配器模式
    设计模式之建造者模式
    设计模式之原型设计
    Exception in thread "main" java.lang.UnsupportedOperationException
    设计模式7大原则
    设计模式之单例模式
    初识python
    消息传递:发布订阅模式详解
    哨兵机制(Redis Sentinel)
  • 原文地址:https://www.cnblogs.com/stevenwuzheng/p/5470034.html
Copyright © 2011-2022 走看看