Jhorra Jhorra - 6 months ago 30
Swift Question

Objective-C Simplest way to create comma separated string from an array of objects

So I have a nsmutablearray with a bunch of objects in it. I want to create a comma separated string of the id value of each object.

Answer

Use the NSArray instance method componentsJoinedByString:.

- (NSString *)componentsJoinedByString:(NSString *)separator.

Example:

NSString *joinedComponents = [array componentsJoinedByString:@","];

Comments