Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

How do you concatenate strings in an array?

join() The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.

What is NSString?

A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.


There are many ways to do it, the simplest being

[yourArray componentsJoinedByString: @","]

Use NSArray's componentsJoinedByString: method.

NSArray *strings = ...;
NSString *combined = [strings componentsJoinedByString:@","];