How do I join an NSSet's elements to create an NSString?
Asked Answered
C

1

21

If I have an NSSet of NSString objects, how can I join them together to create a single NSString?

Chomp answered 17/5, 2011 at 1:24 Comment(0)
S
48

NSSet's -allObjects method will return an NSArray of objects in the receiver.

So, knowing this, it's pretty simple:

[[set allObjects] componentsJoinedByString:@" "];
Separator answered 17/5, 2011 at 1:29 Comment(1)
However, be aware that "The order of the objects in the array isn’t defined."Harken

© 2022 - 2024 — McMap. All rights reserved.