在我的iPhone应用程序中,我将字符串值添加到数组中,首先是strSelectedDir值 xxx-jan16-2011-10.30AM后来它的值为xxx-feb16-2011-02.30PM,我使用以下代码将这两个值添加到数组arrDownloadedDirNames中
[arrDownloadedDirNames addObject:strSelectedDir];
但是在输出数组中,一些新的线符号(\ n)和符号如\“”将如下所示
(
"(\n \"xxx-jan16-2011-10.30AM\"\n)",
"xxx-feb16-2011-02.30PM"
)
but i want array should be like this with no extra symbols other than which are in the input string
(
xxx-jan16-2011-10.30AM ,
xxx-feb16-2011-02.30PM
)
我该怎么做,为什么要添加额外的符号?我怎么能删除那些 请任何人提前帮助我,thanx
答案 0 :(得分:1)
我猜你的字符串来自Parse还是正确的? 您看到的额外符号称为Escape Sequences:
\ n = linebreake \“=”
你可以很容易地替换这个Charakters。
NSMutabeString *yourNewString = [NSMutabelString stringWithFormat:@"%@",[arrDownloadDirNames objectAtIndex:i]
[yourNewString replaceOccurrencesOfString:@"\n \"" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [yourNewString length])];
[yourNewString replaceOccurrencesOfString:@"\"\n" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [yourNewString length])];
干杯 nettz