Jumhyn
Jumhyn

Reputation: 6777

MKMapView centerCoordinate not returning proper values

In my app, I am saving coordinates from an MKMapView into a property list. After the user hits "save" 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?

Upvotes: 0

Views: 530

Answers (2)

Matthew Frederick
Matthew Frederick

Reputation: 22305

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];

Upvotes: 0

nevan king
nevan king

Reputation: 113747

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

Upvotes: 1

Related Questions