When I use componentsJoinedByString, I just get a long string of digits.
Edit: I realize this task is confusing. Why on earth would anyone populate an NSArray with NSNumbers if they wanted an NSString? The answer is that I’m writing an extensible unit test framework. The basic functions genNum, genBool, and genChar generate NSNumbers with random int, BOOL, and char values respectively. Then there’s genArray which generates a random array using a specified generator. So to construct a random NSString, one would run genArray using the genChar generator, and transform the resulting NSArray into an NSString.
The characters are only stored as NSNumbers instead of chars due to a technicality: genArray accepts a block and calls the block 100-odd times to populate the NSArray. Blocks must hold ObjC objects; not primitive types.
So the question remains: How do you join an NSArray of [NSNumber numberWithChar: c]’s into an NSString?
1 Answer