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

Use the NSArray instance method componentsJoinedByString:.

In Objective-C:

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

In Swift:

func componentsJoinedByString(separator: String) -> String

Example:

In Objective-C:

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

In Swift:

let joinedComponents = array.joined(seperator: ",")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)