Objective C NSString 问题 [英] Objective C NSString problem

查看:75
本文介绍了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屋!

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