If I have an NSSet of NSString objects, how can I join them together to create a single NSString?
Asked
Active
Viewed 4,857 times
21
Jacob Relkin
- 161,348
- 33
- 346
- 320
nfm
- 19,689
- 15
- 60
- 90
1 Answers
48
NSSet's -allObjects method will return an NSArray of objects in the receiver.
So, knowing this, it's pretty simple:
[[set allObjects] componentsJoinedByString:@" "];
Jacob Relkin
- 161,348
- 33
- 346
- 320
-
3However, be aware that "The order of the objects in the array isn’t defined." – titaniumdecoy Jan 24 '14 at 00:45