NSNumberFormatter crashing iPhone SDK 4.0b2
Posted
by Ward
on Stack Overflow
See other posts from Stack Overflow
or by Ward
Published on 2010-04-25T02:11:46Z
Indexed on
2010/04/25
2:13 UTC
Read the original article
Hit count: 496
Hey there,
I've got an app that's been in the app store for a while and functions perfectly on OS 3.1 - 3.13. However, when tested on 4.0b2 I noticed that it crashes in the same place every time, but only on the device, never on the simulator. I'm using a 3GS to test.
On loadView I initialize an NSNumberFormatter object which is declared and retained in the interface so I have access to it everywhere. In my method I call it several times to convert string values into nsnumbers to be stored in a mutable dictionary.
Here's an example:
[myDictionary setObject:[myStyleFormatter numberFromString:@"1"] forKey:@"hours"];
[myDictionary setObject:[myStyleFormatter numberFromString:@"30"] forKey:@"minutes"];
[myDictionary setObject:[myStyleFormatter numberFromString:@"10"] forKey:@"seconds"];
For some reason it crashes as soon as it tries to set hours. The error is "attempt to insert nil value (key: hours)"
Have I been doing something wrong all along? Has the api changed for 4.0b2?
Thanks,
Howie
© Stack Overflow or respective owner