Objective-C - 连接由管道分隔的字符串
我想循环遍历数组字符串并将它们添加到 NSString 中:
NSMutableArray *emailsArray = [[NSMutableArray alloc] initWithObjects:@"One", @"Two", @"Three", nil];
for (id email in emailsArray {
NSString *emails = ??;
}
因此最终的 NSString 应该如下所示:
NSString *emails = @"One|Two|Three";
I would like to loop through an array strings and add them to an NSString
in the following way:
NSMutableArray *emailsArray = [[NSMutableArray alloc] initWithObjects:@"One", @"Two", @"Three", nil];
for (id email in emailsArray {
NSString *emails = ??;
}
So the final NSString
should be the following:
NSString *emails = @"One|Two|Three";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,请使用
[emailsArray ComponentsJoinedByString:@"|"]
。示例:
这里您将拥有
emails = @"One|Two|Three"
。Use
[emailsArray componentsJoinedByString:@"|"]
for this.Sample:
Here you'll have
emails = @"One|Two|Three"
.