HI,
Due to formatting issues, I'm converting floats to NSNumber in my iPhone app. Although it generates proper strings it crashes program after releasing the object.
I wrote simple program as console app for Mac OS X and same problem occurs. Can anybody advise how to solve that? Here is the code sample. All 3 messages are written to log and after that EXEC_BAD_ACCESS error occurs...
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *FormattedValueString = [[NSString alloc] init];
NSString *FormattedValueString1 = [[NSString alloc] init];
NSNumber *myNumber = [[NSNumber alloc] initWithDouble:100.345];
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
FormattedValueString = [myNumber stringValue];
FormattedValueString1 = [numberFormatter stringFromNumber:myNumber];
NSLog(FormattedValueString);
NSLog(FormattedValueString1);
[FormattedValueString release];
[FormattedValueString1 release];
[numberFormatter release];
[myNumber release];
NSLog(@"Everything OK");
[pool drain];
return 0;
}