将整数转换为字符串并使用每个字符 [英] Convert integer to string and use each character

查看:140
本文介绍了将整数转换为字符串并使用每个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将整数转换为目标c中的字符串,以及字符串的每个字符是如何到达的?

How is an integer converted to a string in objective c and how is each character of the string reached?

等效于java charAt()方法。

The equivalent to the java charAt() method.

推荐答案

NSString *myString = [NSString stringWithFormat:@"%i", 36];
[myString characterAtIndex:0]; //"3"
[myString characterAtIndex:1]; //"6"

更新:请注意 characterAtIndex 返回一个unichar而不是ac char。谢谢@Chuck。

Update: Note that characterAtIndex returns a unichar not a c char. Thanks @Chuck.

这篇关于将整数转换为字符串并使用每个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆