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 警告

  \b 退格

  \f 换页

  \n 换行

  \r 回车

  \t 跳格Tab

  \v 垂直跳格

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

[BS-15] Values of type 'NSInteger' should not be used as format arguments的更多相关文章

  1. values of type NSInteger should not be used as format arguments; 关于Xcode中烦人的32位与64位警告处理方法.

    http://stackoverflow.com/questions/16075559/why-does-an-nsinteger-variable-have-to-be-casted-to-long ...

  2. The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder is not applicable for the arguments

    The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder i ...

  3. IOS开发基础知识碎片-导航

    1:IOS开发基础知识--碎片1 a:NSString与NSInteger的互换 b:Objective-c中集合里面不能存放基础类型,比如int string float等,只能把它们转化成对象才可 ...

  4. iOS警告收录及科学快速的消除方法

    来自: http://www.cnblogs.com/dsxniubility/p/4757760.html iOS警告收录及科学快速的消除方法     前言:现在你维护的项目有多少警告?看着几百条警 ...

  5. 转载iOS开发中常见的警告及错误

    iOS警告收录及科学快速的消除方法     前言:现在你维护的项目有多少警告?看着几百条警告觉得心里烦么?你真的觉得警告又不是错误可以完全不管么? 如果你也被这些问题困惑,可以和我一起进行下面的操作. ...

  6. iOS 警告收集快速消除

    1.ld: warning: directory not found for option 去掉警告的方法 工程老是提示ld: warning: directory not found for opt ...

  7. iOS 警告收录及科学快速的消除方法

    http://www.cocoachina.com/ios/20150914/13287.html 作者:董铂然 授权本站转载. 前言:现在你维护的项目有多少警告?看着几百条警告觉得心里烦么?你真的觉 ...

  8. IOS开发基础知识--碎片28

    1:通用的weakify和strongify /** * 强弱引用转换,用于解决代码块(block)与强引用self之间的循环引用问题 * 调用方式: `@weakify_self`实现弱引用转换,` ...

  9. iOS:消除项目中警告

    引言: 在iOS开发过程中, 我们可能会碰到一些系统方法弃用, weak.循环引用.不能执行之类的警告. 有代码洁癖的孩子们很想消除他们, 今天就让我们来一次Fuck 警告!! 首先学会基本的语句: ...

随机推荐

  1. Nodejs - windows的系统变量(环境变量)

    我的电脑-属性-高级-环境变量-系统变量(s)-Path 将Node.exe所在的路径插入Path的变量值(V)中 如 ;E:\nodejs\ 最终效果 C:\Windows\system32;C:\ ...

  2. php目录文件下有php-ini-development和php.ini-production。

    1.apache: 只需要你解压到相应目录既可以,比如我这边将下载的apache文件解压到 C:\Apache24: bin目录下有: ApacheMonitor.exe和httpd.exe可用于服务 ...

  3. JS页面跳转 神器! window.href window.open

    window.open 打开页面, 网址为新的网址 window.href 为打开本网址的链接, 为网站URL+传入的URL

  4. typecho插件编写教程1 - 从HelloWorld说起

    typecho插件编写教程1 - 从HelloWorld说起 老高 187 5月25日 发布 推荐 0 推荐 收藏 2 收藏,189 浏览 最近老高正在编写一个关于typecho的插件,由于typec ...

  5. oracle sqlplus常用命令

    登录到sqlplus sqlplus user/pwd@dbname 不登录使用 sqlplus /nolog 查看当前登录用户 show user; 更改用户密码 ALTER USER USER I ...

  6. 制作支持UEFI PC的Server2008 R2系统安装U盘

    下载R2系统 ISO ed2k://|file|cn_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_x6 ...

  7. java MVC架构-spring mvc,struct2(理解)

    MVC架构实现基础: 基于filter或者servlet实现请求地址分析,如果需要控制类处理请求,则调用相应的控制类.调用控制类时,根据配置文件初始化控制类相关的参数.数据库连接可持久化存在.控制类处 ...

  8. Lazarus开发平台编译后的可执行程序的减肥方法

    1.在“工程”菜单下,单击“工程选项”,原始状态的界面为: 2.将界面中的两个选项修改为如下: 3.按“确定”按钮,即可 编译以后的可执行程序就将又原来的14m变为1.66m. 1.选择: Proje ...

  9. java Channel

    Channel Channel与流 基本上,所有的 IO 在NIO 中都从一个Channel 开始.Channel 有点象流.数据可以从Channel读到Buffer中,也可以从Buffer 写到Ch ...

  10. Java Messages Synchronous and Asynchronous

    //The Consumer Class Consumes Messages in a Synchronous Manner public class Consumer { public static ...