Nau*_*tak 12 iphone objective-c
我想在目标c中将int转换为字符串如何做到这一点.
我的代码.
for (i=0; i<=200; i=i+10) {
// here i want to convet the value of i into string how to do this
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
Jac*_*kin 14
试试这个:
NSMutableString *myWord = [[NSMutableString alloc] init];
for (int i=0; i<=200; i=i+10) {
[myWord appendString:[NSString stringWithFormat:@"%d", i]];
//...
}
//do something with myWord...
[myWord release];
Run Code Online (Sandbox Code Playgroud)
NSInteger
是一个简单的typedef
到int
或long
上64分之32位系统的数据类型.
n13*_*n13 13
NSInteger n = 13;
NSString string = @(n).stringValue;
Run Code Online (Sandbox Code Playgroud)
参考文献参见Objective-C文字 - 文字删除了许多丑陋的样板代码,使你的代码库变得混乱:http://clang.llvm.org/docs/ObjectiveCLiterals.html
归档时间: |
|
查看次数: |
20052 次 |
最近记录: |