如何将不同的对象从我的 nsarray 添加到 nsstring

发布于 2024-10-01 15:34:31 字数 153 浏览 0 评论 0原文

我有一个可变数组,它在不同的索引处具有不同的值,例如 指数值 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 技术交流群。

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

发布评论

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

评论(2

梓梦 2024-10-08 15:34:31

您可以使用以下方法:

NSArray *yourArray;
NSString *createdString = [yourArray componentsJoinedByString:@" "];

用空格分隔数组组件。

这是 NSArray< 的文档/代码>。以下是消息的文档 componentsJoinedByString

You can use this:

NSArray *yourArray;
NSString *createdString = [yourArray componentsJoinedByString:@" "];

Separating array components with a space.

Here's documentation for NSArray. Here's documentation for message componentsJoinedByString.

穿透光 2024-10-08 15:34:31

您可以将字符串附加到一起
[NSString stringWithFormat:@"%@ %@ %@", string1,string2,string3];

You can append strings together with
[NSString stringWithFormat:@"%@ %@ %@", string1,string2,string3];

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