将数组复制到字符串并按顺序显示字符串
我正在将 NSMutableArray 复制到字符串。当我显示字符串时,我在数组项之前得到一个“(”符号,数组项之间用逗号分隔。我想逐行显示数组项,而不是用逗号分隔。我怎样才能这样做
I am copying an NSMutableArray to a string. When I am displaying the string I am getting a "(" sign before the array items and the array entries are separated by a comma in between. I want to display the array entries line by line, and not by comma separated. How can I do this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有多种方法可以做到这一点。如果您只想用换行符加入数组,最简单的方法是使用
NSArray
的 -componentsJoinedByString: 方法。例如,要完全按照您的要求进行操作:There are a number of ways to do this. If you just want to join the array with a new-line character, the easiest is to use
NSArray
's -componentsJoinedByString: method. For example, to do exactly what you asked:您可以尝试
这将用新行字符替换所有左大括号。对右大括号执行相同的操作。
You can try
This will replace all the opening braces with a new line character.Do the same for closing brace.