Objective C NSString 问题 [英] Objective C NSString problem
本文介绍了Objective C NSString 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 NSString,我需要逐个字符地检查它,并且:
I have a NSString that I need to examine character by character and:
examine char
perform calculation
loop (until string ends)
对执行此操作的最佳方法有任何想法吗?我需要转换 NSString到 NSArray 或 C 字符串?
Any thoughts on the best way to do this? Do I need to convert the NSString to a NSArray or C string?
推荐答案
最简单的方法是使用 NSString
的 characterAtIndex:
方法:
The simplest way to go about it is using NSString
's characterAtIndex:
method:
int charIndex;
for (charIndex = 0; charIndex < [myString length]; charIndex++)
{
unichar testChar = [myString characterAtIndex:charIndex];
//... your code here
}
这篇关于Objective C NSString 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文