2月份开始苹果app必须支持arm64了,支持以后会有一个问题,
NSInteger变成64位了,和原来的int (%d)不匹配,会报如下warning,
Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead
修改方法如下:
NSInteger number = 0;
NSString *str = [NSString stringWithFormat:@"%d", number];
假如number这个值32位足够了,
1、可以更改数字定义为int number = 0;
强转型
2、[NSString stringWithFormat:@"%d", (int)number];
32位可能不够的话
3、[NSString stringWithFormat:@“%ld", (long)number];
一般双击代码左边黄色标签,系统会默认弹出选择用第三种方法替换
4、[NSString stringWithFormat:@“%@", @(number)];
随着苹果要求App必须支持ARM64, 开发者面临NSInteger类型与%d格式字符串不匹配的问题。本文介绍如何通过调整变量类型或使用强制类型转换解决这一警告。
337

被折叠的 条评论
为什么被折叠?



