Programming Reference/Librarys
Question & Answer
Q&A is closed
- (NSString *)descriptionWithLocale:(id)aLocale
Returns a string that represents the contents of the receiver for a given locale.
//** Sample Datatypes ** int myInt= 1000000; double myDouble = 3.14; float myFloat = 1.123456f; char myChar = 'w'; //** Initializing NSNumber Objects ** NSNumber *myIntNumber = [[NSNumber alloc]initWithInt:myInt]; NSNumber *myDoubleNumber = [[NSNumber alloc]initWithDouble:myDouble]; NSNumber *myFloatNumber = [[NSNumber alloc]initWithFloat:myFloat]; NSNumber *myCharNumber = [[NSNumber alloc]initWithChar:myChar]; //Use "nil" if you don’t want the description formatted. NSLog(@"myIntNumber(Locale: nil): %@", [myIntNumber descriptionWithLocale:nil]); NSLog(@"myFloatNumber(Locale: nil): %@", [myFloatNumber descriptionWithLocale:nil]); NSLog(@"myDoubleNumber(Locale: nil): %@", [myDoubleNumber descriptionWithLocale:nil]); NSLog(@"myCharNumber(Locale: nil): %@", [myCharNumber descriptionWithLocale:nil]);
2012-07-16 00:12:57.484 NSNumberSample[856:f803] myIntNumber(Locale: nil): 1000000 2012-07-16 00:12:57.503 NSNumberSample[856:f803] myFloatNumber(Locale: nil): 1.123456 2012-07-16 00:12:57.504 NSNumberSample[856:f803] myDoubleNumber(Locale: nil): 3.14 2012-07-16 00:12:57.505 NSNumberSample[856:f803] myCharNumber(Locale: nil): 119