Is it possible to use format strings to align NSStrings like numbers can be?
I'm using NSLog() to print some tabular data consisting of an NSString and an associated integer . Assume I know the length of the longest word. Is there a way using format strings to get this kind of column alignment: word:tree rank:5 word:frog rank:3 word:house rank:2 word:peppercorn rank:2 word:sword rank:2 word:antlion rank:1 The reason I'm asking about formatting strings is I'm hoping for a lightweight way to format my ghetto debugging output. Here is what I tried: NSString *word = @"tree"; NSUInteger rank = 4; NSString *str = [NSString stringWithFormat:@"word:%-20@ rank:%u", word, rank];