description(withLocale:)
Returns a string that represents the contents of the number object for a given locale.
Declaration
func description(withLocale locale: Any?) -> StringParameters
- locale:
An object containing locale information with which to format the description. Use
nilif you don’t want the description formatted.
Return Value
A string that represents the contents of the number object formatted using the locale information in locale.
Discussion
For example, if you have an NSNumber object that has the integer value 522, sending it the description(withLocale:) message returns the string “522”.
To obtain the string representation, this method invokes NSString’s initWithFormat:locale: method, supplying the format based on the type the NSNumber object was created with:
Data Type | Format Specification |
|---|---|
char | %i |
double | %0.16g |
float | %0.7g |
int | %i |
long | %li |
long long | %lli |
short | %hi |
unsigned char | %u |
unsigned int | %u |
unsigned long | %lu |
unsigned long long | %llu |
unsigned short | %hu |