将 NSString 的 NSArray 转换为 NSMutableString 的 NSArray
如何做到这一点而不必使用“for”循环“滚动”整个给定数组?
How to do that without having to "scroll" the entire given array with a "for" loop?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我能想到的最好的办法是:
这或多或少只是告诉
originalArray
为您构建for循环。如果有什么不同的话,那就是比以下更多的工作:The best I can come up with is:
Which more or less just tells the
originalArray
to construct the for loop for you. And if anything it's more work than:因为似乎没有人同意我的评论,即这是 将 NSNumbers 的 NSArray 转换为 NSStrings 数组的更好方法,这里又是相同的答案:
来自
Since nobody seems to agree with my comment that this is a duplicate of Better way to convert NSArray of NSNumbers to array of NSStrings, here's the same answer again:
From the docs:
我在 NSArray 上编写了一个字典方法,以便能够编写更清晰的函数代码
用法:
这受到我从 Python 中了解的列表理解的启发。我还通过测试编写了该方法的版本。请参阅我的 arraytools。
I wrote a dictionary method on NSArray to be able to write cleaner functional code
usage:
This was inspired by list comprehensions I know from Python. I also wrote versions of this methods with testing. See my arraytools.