I have an object in my account array with a value of 8500.00. I'd like to display that as 8,500.00 but when I try to do so and print to the console it returns null. Any ideas?
App Delegate
NSArray *balance = [[NSArray alloc] initWithObjects:@"120.50", @"8500.00", nil];
// View controller
// Setup number formatter
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *balance = [[appDelegate.accounts objectForKey:@"Available Balance"] objectAtIndex:indexPath.row];
NSLog(@"%@", balance); // Prints 8500.00
NSLog(@"%@", [formatter stringFromNumber:balance]); // Prints null
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…