You can always make an array from a set, for example:
NSArray *myArray = [mySet allObjects];
After that, you can get your string with componentsJoinedByString::
NSString *str = [myArray componentsJoinedByString:@", "];
Of course, you can achieve the same effect with a simple loop similar to the one indicated in your post:
BOOL isFirst = YES;
for (id element in mySet) {
if (!isFirst) {
[outputStringArray appendString:@", "];
} else {
isFirst = NO;
}
[outputStringArray appendFormat:@"%@", element];
}
source
share