[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' insteadapp

 

解决办法:spa

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

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

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

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

补充:string

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

 

C语言转义字符

     \\ 反斜杠编译

  \a 警告ast

  \b 退格

  \f 换页

  \n 换行

  \r 回车

  \t 跳格Tab

  \v 垂直跳格

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

相关文章
相关标签/搜索