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. Asp反向代理程序,调用远程站点全站数据,一款脚本级反向代理程序.

    前些天临时写的一脚本级反向代理程序,用法很简单,设置好目标站地址,然后放到你网站根目录:index.asp,再将404页面自定义为:index.asp,即可. 由于暂时没有 url 替换需要,所以没有 ...

  2. 【液晶模块系列基础视频】5.4.X-GUI字体驱动4

    ============================= 技术论坛:http://www.eeschool.org 博客地址:http://xiaomagee.cnblogs.com 官方网店:ht ...

  3. 使用Android Studio和Genymotion模拟器搭建Andriod开发环境

    一.Android Studio下载 1.打开http://www.android.com/ 2.依照下图步骤打开下载页面 a.在页脚部分点击“App Developer Resources” b.点 ...

  4. mysql 导入导出.sql文件

    备份数据库(包含全部表和全部存储过程):C:\Documents and Settings\Administrator>mysqldump -h localhost -u root -p -R ...

  5. P1083 借教室

    思路:前缀和, c表示对于当前的middle, 前缀和 #include <bits/stdc++.h> using namespace std; const int maxn = 1e6 ...

  6. P2409 Y的积木

    luogu月赛 暴力dfs,估计过不了几个点,大概也就得30分左右? #include <bits/stdc++.h> using namespace std; const int max ...

  7. BAE3.0上的java+tomcat+hibernate代码发布

    在BAE上使用hibernate说起来也简单,但因为一个不小心,耽误了好几个小时. 百度文档中有说: http://developer.baidu.com/wiki/index.php?title=d ...

  8. java ObjectOutputStream

    import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import ...

  9. The Producer-Consumer Relationship Version 2

    Listing -. The Producer-Consumer Relationship Version public class PC { public static void main(Stri ...

  10. CC2541连接BTool教程

    一.简介 本篇介绍如何基于Smart RF(主芯片CC2541).Smart RF(主芯片CC2540).Usb Dongle,来使用软件BTool. 本篇暂时只介绍如何连接,不介绍如何使用BTool ...