数组有额外的符号,而不是我添加的,使用 Objective C 修剪 iPhone 应用程序中的数组

发布于 2024-12-01 06:29:24 字数 599 浏览 1 评论 0原文

在我的 iPhone 应用程序中,我将字符串值添加到数组中,第一个 strSelectedDir 值将是 xxx-jan16-2011-10.30AM 稍后其值将是 xxx-feb16-2011-02.30PM ,,我使用以下代码将这 2 个值添加到数组 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
)

我该怎么做,为什么要添加额外的符号?我怎样才能删除那些 请任何人帮助我,提前致谢

in my iphone app i am adding string values to the array first strSelectedDir value ill be
xxx-jan16-2011-10.30AM later its value ill be xxx-feb16-2011-02.30PM ,,i am adding these 2 values into the array arrDownloadedDirNames using the following code

 [arrDownloadedDirNames addObject:strSelectedDir];

but in the out put array some new line symbols(\n) and symbols like \ "" are coming as shown bellow

(
    "(\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
)

how can i do this, why extra symbols are added? how can i remove those
please can any one help me,, thanx in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心荒芜 2024-12-08 06:29:24

我猜你的字符串来自 Parse 或者其他什么,对吗?
您看到的额外符号称为转义序列:

\n = linebreake
\" = "

你可以很容易地替换这个角色。

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])];

干杯
内茨

I guess your String is from a Parse or something right?
The extra symbols you see are called Escape Sequences:

\n = linebreake
\" = "

You can replace this Charakters pretty easy.

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])];

Cheers
nettz

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文