I’m trying to create a string containing (unicode) ‘stars’ based on an integer rating. I currently have:
NSMutableString *stars = [NSMutabelString stars];
for (int i = 0; i < rating; i++)
{
[stars appendString:@"\u2605"];
}
However, I find this a bit ugly. Does a way exist to construct such a string without using this looping method? Something using the string formats?
Sure – to do this on a single line you can use the
stringByPaddingToLengthmethod:…should hopefully do the trick for you – and no need to create any subclasses or categories, etc!