Argument för initWithFormat:?

Tråden skapades och har fått 2 svar. Det senaste inlägget skrevs .
1

Någon som vet var man hittar en komplett lista över format-argumenten till strängfunktionen:

- (id)initWithFormat :(NSString *)format,...

Exempel:

%d - integer
%s - C-string
%@ - NSString

/Jont Olof

  • Medlem
  • International user
  • 2002-02-21 09:50

Det är alla format som funkar med printf plus %@.

man printf
[snip]
The format characters and their meanings are:

diouXx The argument is printed as a signed decimal (d or i), un-
signed octal, unsigned decimal, or unsigned hexadecimal (X or
x), respectively.

f The argument is printed in the style [-]ddd.ddd where the
number of d´s after the decimal point is equal to the preci-
sion specification for the argument. If the precision is
missing, 6 digits are given; if the precision is explicitly
0, no digits and no decimal point are printed.

eE The argument is printed in the style [-]d.ddde+-dd where
there is one digit before the decimal point and the number
after is equal to the precision specification for the argu-
ment; when the precision is missing, 6 digits are produced.
An upper-case E is used for an `E´ format.

gG The argument is printed in style f or in style e (E) whichev-

er gives full precision in minimum space.

b Characters from the string argument are printed with back-
slash-escape sequences expanded.

c The first character of argument is printed.

s Characters from the string argument are printed until the end
is reached or until the number of characters indicated by the
precision specification is reached; however if the precision
is 0 or missing, all characters in the string are printed.

% Print a `%´; no argument is used.
[snip]

[ 21 Februari 2002: Meddelandet ändrat av: kent ]

Tack för det!!

/Jont Olof

1
Bevaka tråden