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 垂直跳格
空格在輸入時不需要轉義,直接敲空格