如何将整数转换为字符串? [英] how to convert integer to string?
本文介绍了如何将整数转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
如何从 int 转换为 string in目标 c:示例代码...
在Objective C中如何将整数转换为字符串?
How to convert integer to string in Objective C?
推荐答案
NSArray *myArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:1], [NSNumber numberWithInt:2], [NSNumber numberWithInt:3]];
更新新的 Objective-C 语法:
Update for new Objective-C syntax:
NSArray *myArray = @[@1, @2, @3];
从编译器的角度来看,这两个声明是相同的.
Those two declarations are identical from the compiler's perspective.
如果您只是想在字符串中使用整数来放入文本框或其他内容:
if you're just wanting to use an integer in a string for putting into a textbox or something:
int myInteger = 5;
NSString* myNewString = [NSString stringWithFormat:@"%i", myInteger];
这篇关于如何将整数转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文