如何将不同的对象从我的 nsarray 添加到 nsstring
我有一个可变数组,它在不同的索引处具有不同的值,例如 指数值 0 你好 1 这个 2 是 3部苹果手机 4 测试。
因此,在不同的索引处,数组具有不同的字符串值,现在我希望将其放入一个字符串中,该字符串的内容为“嗨,这是 iphone 测试”。
谢谢。
I am having a mutable array which has differnt value at differert index such as at
index value
0 Hi
1 this
2 is
3 iphone
4 testing.
So at differnt index ,array has different string value now i want this into one string which has reads as Hi this is iphone testing.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下方法:
用空格分隔数组组件。
这是
NSArray< 的文档/代码>
。以下是消息的文档
componentsJoinedByString
。You can use this:
Separating array components with a space.
Here's documentation for
NSArray
. Here's documentation for messagecomponentsJoinedByString
.您可以将字符串附加到一起
[NSString stringWithFormat:@"%@ %@ %@", string1,string2,string3];
You can append strings together with
[NSString stringWithFormat:@"%@ %@ %@", string1,string2,string3];