NSArray 问题 - \n\t\t 被添加到字符串末尾?
我的字符串很好,但是当它们添加到数组中时,末尾会添加一个奇怪的“\n\t\t”分组。因此,当我查看数组描述时,字符串“Apple”变为“Apple\n\t\t”。
这有什么关系?我该如何解决它?
添加:
其 XML 代码。看起来像 [currentPlace appendString:string];会得到正确的部分,然后在下一轮添加\n\t\t。我通过交替使用布尔值解决了这个问题:
if (alternate == NO) {
[currentPlace appendString:string];
alternate = YES;
} else {
alternate = NO;
}
有更好的交替方法吗?我记得有一个case+break way,但是我忘了怎么做。
My strings are fine, but when they get added to an array a weird grouping of "\n\t\t" gets added to the end. So the string "Apple", becomes "Apple\n\t\t" when I look at the array description.
Whats the deal with that? and how do I fix it?
Addition:
Its XML code. It seemed like [currentPlace appendString:string]; would get the right part, then add the \n\t\t next time round. I solved this by alternating using a boolean:
if (alternate == NO) {
[currentPlace appendString:string];
alternate = YES;
} else {
alternate = NO;
}
Is there a better way to alternate? I remember there being a case + break way, but I forget how to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将字符串添加到数组显然不会修改其内容。你的错误在其他地方,你没有描述的程序的一部分。没有代码,没有人能够帮助您。
Adding strings to an array obviously does not modify their contents. Your bug is somewhere else, a part of your program you did not describe. Without code, nobody would be able to help you.
我通过添加一个开关来解决这个问题:
现在一切都很好。
I solved this by adding a switch to:
All is good now.