开发者

MKMapView centerCoordinate not returning proper values

In my app, I am saving coordinates from an MKMapView into a property list. After the user hits "sav开发者_Python百科e" I set the center coordinate of the selection view to that on the main view, and then save the mapView.centerCoodinate.latitude and longitude into a pList. However, this gives me a value like "1078114215" which the map says is not a vail coordinate. What am I doing wrong?


Saving a pointer instead of the two floats in the coordinate? Not saving as a float?


Sounds like you're accidentally mis-typing your double variable. When you add it to your dictionary to be stored as a plist be sure to transform it from a double to an NSNumber like this:

[myDictionary addObject:[NSNumber numberWithDouble:latitude] forKey:@"latitude"];

and when you retrieve it, transform it from an NSNumber to a double:

double latitude = [[myDictionary objectForKey:@"latitude"] doubleValue];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜