访问Plist中的坐标 – iOS

而不是如下所示访问硬编码的特定纬度

NSString *path = [[NSBundle mainBundle] pathForResource: @"WellList" ofType:@"plist"]; NSMutableDictionary *root = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; NSString* latitude = [[[[[root objectForKey: @"Routes"] objectForKey: @"Houston" ] objectForKey: @"Location 1"] objectForKey: @"coordinate"] objectForKey: @"latitude"]; 

我想使用循环访问我的plist中的每个坐标,并将它们添加到我的NSmutableArray。

在这里输入图像说明

 NSMutableDictionary *root = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; NSDictionary *routes = [root objectForKey: @"Routes"]; NSArray *cities = [routes allValues]; for (NSDictionary *city in cities) { NSArray *locations = [city allValues]; for (NSDictionary *loc in locations) { NSDictionary *coord = [loc objectForKey:@"coordinate"]; NSLog(@"%@",[coord objectForKey:@"latitude"]); } }