Objective C - 如何连接整个字符串数组? [英] Objective C - How to concatenate an entire array of strings?

查看:56
本文介绍了Objective C - 如何连接整个字符串数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个 Objective C 新手.我想编写一个方法,它接受一个字符串数组并返回一个连接的字符串,每个字符串之间有一个逗号 (,).所以如果一个数组是 {a b c d},我想返回 a,b,c,d.

I am an Objective C newbie. I want to write a method that takes in an array of strings and returns a concatenated string, with a comma (,) in between each string. So if an array is {a b c d}, I want to return a,b,c,d.

最简单的方法是什么?

推荐答案

有很多方法可以做到,最简单的是

There are many ways to do it, the simplest being

[yourArray componentsJoinedByString: @","]

这篇关于Objective C - 如何连接整个字符串数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆