I’m trying to pass some lat/long values from a JSON doc to iPhone’s Map Kit to then plot the points on the map. The values are coming from an NSArray:
CGFloat goLat = [valfields objectForKey: @"geo_lat"];
CGFloat golong = [valfields objectForKey: @"geo_long"];
CLLocationCoordinate2D newCoord = {golat, golong}; etc...
But I’m getting an “incompatible types” error.
My guess is I need to cast the string values from my array to CGFloat? But I’m just sure.
Any thoughts?
Thanks,
g
‘Casting’ isn’t what you need to do, but if your array (actually from your code it looks like a dictionary) contains strings, then yes, you need to convert them to a numeric format. Give this a try:
From the NSString documentation:
In addition,
NSStringhas a-doubleValuemethod. There is also anNSNumberclass, which might be a better representation than strings for your data.