Objective-C - NSInteger转换NSString

Posted blfbuaa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Objective-C - NSInteger转换NSString相关的知识,希望对你有一定的参考价值。

NSInteger不是对象, 转换为long匹配64位系统, 再组成字符串(%ld).

NSString *inStr = [NSString stringWithFormat: @"%ld", (long)month];

Note that on 64-bit processors, such as the new A7 chip, if your app is compiled for 64-bit, an NSInteger is actually a long, not an int. Doing the cast, (int)month would be destructive on 64-bit platforms for the generic case. If targeting Apple platforms exclusively, something similar that will work with both int and long – e.g. long.


技术分享

以上是关于Objective-C - NSInteger转换NSString的主要内容,如果未能解决你的问题,请参考以下文章

将 int64_t 转换为 NSInteger

如何在objective-c中将字节值转换为int

objective-c 参数未正确传递

Objective-C:将两个整数相除并返回一个四舍五入的整数值

int、NSInteger 和 NSUInteger 的区别

NSString 和NSInteger的相互转换