NSString stringWithFormat question

Posted by John Smith on Stack Overflow See other posts from Stack Overflow or by John Smith
Published on 2010-04-23T18:10:19Z Indexed on 2010/04/23 18:13 UTC
Read the original article Hit count: 255

I am trying to build a small table using NSString. I cannot seem to format the strings properly.

Here is what I have

[NSString stringWithFormat:@"%8@: %.6f",e,v]

where e is an NSString from somewhere else, and v is a float.

What I want is output something like this:

Grapes:       20.3
Pomegranates:  2.5
Oranges:      15.1

What I get is

Grapes:20.3
Pomegranates:2.5
Oranges:15.1

How can I fix my format to do something like this?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa