I've been having some trouble getting NSNumberFormatter to work properly.
I'm compiling in iOS4 with the Three20 Framework.
All of the NSNumberFormatter selectors require something called NS_AVAILABLE as a second parameter on the selector:
[numberFormatter setCurrencyGroupingSeparator:(NSString *)string __AVAILABILITY_INTERNAL__IPHONE_2:(int)_0];
I'm not sure what I'm supposed to do with the second parameter. I've tried:
[numberFormatter setCurrencyGroupingSeparator:@"," __AVAILABILITY_INTERNAL__IPHONE_2:2]; // Warning: NSNumberFormatter' may not respond to '-setCurrencyGroupingSeparator:__AVAILABILITY_INTERNAL__IPHONE_2:
[numberFormatter setCurrencyGroupingSeparator:@"," __AVAILABILITY_INTERNAL__IPHONE_2:2_0]; //Error: invalid suffix "_0" on integer constant
and several more iterations of that.
If I don't specify the __AVAILABLE_INTERNAL__IPHONE_2 it doesn't throw a warning and compiles fine, but the selector text is black, not dark purple in Xcode as if it's not recognized.
Here's the full code snippet:
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setCurrencyGroupingSeparator:@","];
[numberFormatter setUsesGroupingSeparator:YES];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
numberString = [NSString stringWithFormat: @"$%@",[numberFormatter stringFromNumber:myNsNumber]]; // myNsNumber is an NSNumber with a value of 10000000
NSLog(@"numberString: %@",numberString); // numberString: (null) | instead of numberString: $10,000,000
I've Googled _AVAILABILITY_INTERNAL__IPHONE_2 and NS_AVAILABLE with no luck.
Searching developer.apple.com only gives me the iOS 4.0 API Diffs.
Is this an issue with Three20? Does anyone know whats going on here or what NS_AVAILABLE is all about?