How to convert a number in a NSString ?
09/07/03 22:48
Various ways to convert a numerical value into a string using Cocoa classes…
Objective-C being C: you can use any standard C routine to do the job: printf family being one of them.
A more Cocoa way ?
NSString class offers the [NSString stringWithFormat:] as a direct equivalent to the standard printf, and a more powerful initWithFormat family of instance methods that may use a locale NSDictionary to take into account end-users settings.
NSNumber has a bunch of initWithXXX methods to initialize an instance with a specific data type (int, BOOL, float, long long, etc.). Then you can create a NString from a NSNumber using description and descriptionWithLocale methods.
A more Cocoa way ?
NSString class offers the [NSString stringWithFormat:] as a direct equivalent to the standard printf, and a more powerful initWithFormat family of instance methods that may use a locale NSDictionary to take into account end-users settings.
NSNumber has a bunch of initWithXXX methods to initialize an instance with a specific data type (int, BOOL, float, long long, etc.). Then you can create a NString from a NSNumber using description and descriptionWithLocale methods.