有没有人知道如何从plist加载纬度和经度数据?这是plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>PlaceName</key>
<string>Aquaria Ocenarium</string>
<key>PlaceMenuImage</key>
<string>1.png</string>
<key>PlaceInfo</key>
<string>Visit Aquaria KLCC to discover marine life from both Malaysian waters and around the world. Aquaria also conducts feeding sessions and a 3-D movie.</string>
<key>GetThere</key>
<string>By Train: The KLCC station is on the PUTRA LRT line. Aquaria is a short walk to KLCC Convention Centre via an underground tunnel or through the KLCC park.</string>
<key>Latitude</key>
<real>3.153928</real>
<key>Longitude</key>
<real>101.713529</real>
</dict>
</array>
这里是ViewController.m的代码
- (void)viewDidLoad
{
[super viewDidLoad];
// Init place array
_places = [NSMutableArray array];
// Find out the path of bnm.plist
NSArray *data = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"gokl" ofType:@"plist"]];
NSLog(@"%@", data);
for (NSInteger i = 0; i < data.count; i++)
{
MCWPlaces *placeGO = [MCWPlaces new];
placeGO.name = [[data objectAtIndex:i] objectForKey:KEY_PLACE_NAME];
placeGO.info = [[data objectAtIndex:i] objectForKey:KEY_PLACE_INFO];
placeGO.imageMenu = [[data objectAtIndex:i] objectForKey:KEY_PLACE_MENU_IMAGE];
placeGO.getThere = [[data objectAtIndex:i] objectForKey:KEY_GET_THERE];
placeGO.latitude = [[data objectAtIndex:i] objectForKey:KEY_LATITUDE];
placeGO.longitude = [[data objectAtIndex:i] objectForKey:KEY_LONGITUDE];
[_places addObject:placeGO];
}
NSLog(@"%@", _places);
}
这里是MapViewController.m的代码
- (void)viewWillAppear:(BOOL)animated {
// 1
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = (CLLocationDegrees) [place.latitude floatValue];
zoomLocation.longitude= (CLLocationDegrees) [place.longitude floatValue];
// 2
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);
// 3
[mapView setRegion:viewRegion animated:YES];
}
经度和纬度数据没有像在plist中那样加载。日志显示经度= 0.000000和纬度= 0.000000。我的代码有什么问题吗?