Re: Simple Question
Re: Simple Question
- Subject: Re: Simple Question
- From: "Erik M. Buck" <email@hidden>
- Date: Sun, 11 Nov 2001 23:35:58 -0600
<Quote>
I have a text field that has to display a combination of NSString and a
calculated float value. I can't find any details on how to convert the
float in a NSString to display it together in the text field.
I realize that this is most likely and very simple answer, but I am at the
end of my rope trying to find it.
<END Quote>
stringWithFormat:
+ (id)stringWithFormat:(NSString *)format, ...
Returns a string created in the manner of localizedStringWithFormat:, but
using the default locale to format numbers. See "Creating and Converting
String Objects" in the class description for more information.
See Also: - initWithFormat:
or NSNumber's
stringValue
- (NSString *)stringValue
Returns the receiver's value as a human-readable NSString, by invoking
descriptionWithLocale: where locale is nil.
Since we are on the subject of newbies not being able to find information,
why couldn't you find these references or the many times this question has
been answered in this forum before ? Rather than shouting RTFM at you, we
can use this question as a test case for why this information was hard to
find ?
- Have you ever used printf() in ANSI C ?
- Did you consider just using sprintf() ?
- Did you glance at the NSString documentation ? If not why ? In your
question, you state that you want and NString containing text and a number.
Why didn't you just scan the NSString documentation ?
- Did you scan the NSString and or NSNumber documentation and not suspect
that a format could help you ? Did you not think that -stringValue of a
number could help ?
- Did you notice that strings can be appended to each other in a variety of
ways ?
I am not picking on you. I think you can help many people understand what
exactly is missing from the documentation.