Not sure what I'm missing here, so thanks for any help.
I am parsing some XML into a variety of strings. A few of them are digit strings (latitude or longitude), that I need to use as doubles. But when I convert them, they turn into zero.
have you tried using floatValue instead of doubleValue? I don't know why but I had some trouble using doubles as well the other day that I didn't have using float. It's a rather random guess but maybe it helps.
Cheers,
Bob
__________________ We are God’s middle children, according to Tyler Durden, with no special place in history and no special attention.
QUOTE=RobotWoods;213248]
NSLog(@"double: %d", newDouble);[/php]
[/quote]
The format specifier "%d" is for integers, not for doubles. Doubles are specified by "%f".
Last edited by RLScott; 06-22-2010 at 08:18 AM.
Reason: Corrected "%lf" to "%f"
Not sure what I'm missing here, so thanks for any help.
I am parsing some XML into a variety of strings. A few of them are digit strings (latitude or longitude), that I need to use as doubles. But when I convert them, they turn into zero.
The format specifier "%d" is for integers, not for doubles. Doubles are specified by "%lf".
My mistake. The correct specifier for doubles is just "%f". But I was right that "%d" is for 32-bit integers. So you cannot trust it to correctly render a double.
Robert, thanks for the suggestion, I have tried floatValue, as well as using CGFloat as the type for the new item. I have also tried Scanner and NumberFormatter to no avail, I am jack's seething frustration.
Juan, the issue is that "someStrings" has multiple attributes/elements, so in actuality there is a someStrings.latitude and someStrings.longitude
And RLScott, thanks for pointing that out, but regardless of my NSLog syntax, when I try to USE these numbers (as lat/long of a pin annotation) it's always landing at (0,0).
I found that if floatValue / doubleValue are trying to convert an "invalid number" they just return zero, so I think that is the issue, but just what about these numbers is invalid is escaping me...the XML file that I'm pulling from is generated via PHP, so I don't know if there is some encoding detail I need to change/convert.
Thank you all for your suggestions, I am away from my mac for the time being, but will bang my head against it again tonight.
with the understanding that NSXMLParser would only grab the string between the start and end of the elements, but somehow the newline was getting included, making the string of digits an invalid number...