Objective C - How to concatenate an entire array of strings?

Suchi picture Suchi · Oct 5, 2011 · Viewed 22k times · Source

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.

What is the easiest way to do that?

Answer

user747858 picture user747858 · Oct 5, 2011

There are many ways to do it, the simplest being

[yourArray componentsJoinedByString: @","]