My iphone app is accessing a JSON service which returns something like:
{"theResult":{"Total":1.5, "Comment":"some comment"}}
The code I’m using successfully parses any NSStrings such as the comment field above but I am having trouble with numeric values.
NSDictionary *res= [json objectForKey:@"theResult"];
NSString *comment = [res objectForKey:@"Comment"];
NSDecimal *total = (__bridge NSDecimal *)[res objectForKey:@"Total"];
The *total variable does not get set correctly and causes a EXC_BAD_ACCESS error.
How do I parse numeric values in objective-c?
convert the object to the correct data type, like this