我解析了一个包含需要在屏幕上显示的字符串的xml。这是执行此操作的代码。无法对存储在NSMutableArray中的字符串使用componentsSeparatedByString
[gTutorialTextList addObject:[attributeDict objectForKey:@"value"]];
这里值是其中包含的XML文本和gTutorialTextList是我的NSMutableArray属性。
我需要的是我需要分手时\ n进来的字符串。这是执行该操作的代码。
[[gTutorialTextList objectAtIndex:0] componentsSeparatedByString:@"\n"];
但现在我无法做到这一点。我没有收到由\ n分开的字符串数组。当我直接把NSString,它工作正常。
请帮忙。我想我正确地表达了我的怀疑。
在此先感谢。
这里有输出。 - > \ nSample Text \ nSample Text \ nSample Text < - 。并且文本数组的输出是( “\\ nSample Text \\ nSample Text \\ nSample Text” ) – Aaron 2011-02-23 13:38:18
@Aaron看起来您在输入字符串中有一个真实的反斜杠。试着用[[[gTutorialTextList objectAtIndex:0] componentsSeparatedByString:@“\\ n”];' – Jilouc 2011-02-23 14:29:05
@Jilouc Thankz buddy ...我弄明白了。以前当我直接使用NSString时,这不是问题。因此我在解析的字符串上犯了错误。 – Aaron 2011-02-24 09:10:21