String Formatting Tricks/Docs

Posted by Meltemi on Stack Overflow See other posts from Stack Overflow or by Meltemi
Published on 2010-04-23T19:47:00Z Indexed on 2010/04/23 19:53 UTC
Read the original article Hit count: 450

Was reading the response by Shaggy Frog to this post and was intrigued by the following line of code:

NSLog(@"%@", [NSString stringWithFormat:@"%@:%*s%5.2f", key, padding, " ", [object floatValue]]);

I know string formatting is an age old art but I'm kinda doing the end around into Cocoa/Obj-C programming and skipped a few grades along the way. Where is a good (best) place to learn all the string formatting tricks allowed in NSString's stringWithFormat? I'm familiar with Apple's String Format Specifiers page but from what I can tell it doesn't shed light on whatever is happening with %*s or the %5.2f (not to mention the 3 apparent placeholders followed by 4 arguments) above?!?

© Stack Overflow or respective owner

Related posts about string

Related posts about string-manipulation