Objective C - How to concatenate an entire array of strings?
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?
There are many ways to do it, the simplest being
[yourArray componentsJoinedByString: @","]
Use NSArray's componentsJoinedByString:
method.
NSArray *strings = ...;
NSString *combined = [strings componentsJoinedByString:@","];