Iphone 使用NSMutableArray进行地图注释

Iphone 使用NSMutableArray进行地图注释,iphone,objective-c,sdk,Iphone,Objective C,Sdk,我用XML praser中的对象填充了NSMutablearray。我现在知道如何使用它来填充地图注释。我让这个数组用于我的表,它将对象带入单元格,但我想对我的映射使用相同的NSMutablearray //currentBranch is filled with my Objects Mapdets *currentBranch = [[xmlParser branch]]; [mapview setMapType:MKMapTypeStandard]; [mapview setZoom

我用XML praser中的对象填充了NSMutablearray。我现在知道如何使用它来填充地图注释。我让这个数组用于我的表,它将对象带入单元格,但我想对我的映射使用相同的NSMutablearray

//currentBranch is filled with my Objects
Mapdets *currentBranch = [[xmlParser branch]];



[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];

MKCoordinateRegion region = {{0.0, 0.0}, {0.0,0.0 }};
region.center.latitude = -33.86434888;
region.center.longitude = 151.2090236;
region.span.longitudeDelta = 0.10f;
region.span.latitudeDelta = 0.10f;
[mapview setRegion:region animated:YES];




 //Annotation code will go here. Need help with that.
好的,这就是我要说的。我有一个数组,里面填充了标题、子文件、纬度、经度,我想基本上用xpold这个数组并使用元素

谢谢你的帮助

如果我运行NSLog(@“%@”,currentBranch),我的数组将被填充

这一切都正常工作了,我现在只想在另一个类中为我的映射使用这个NSMutablearray。

在Appdelegate中使用分支(
NSMutablearray
),然后

//currentBranch is filled with my Objects
Mapdets *currentBranch = [[xmlParser branch]];



[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];

MKCoordinateRegion region = {{0.0, 0.0}, {0.0,0.0 }};
region.center.latitude = -33.86434888;
region.center.longitude = 151.2090236;
region.span.longitudeDelta = 0.10f;
region.span.latitudeDelta = 0.10f;
[mapview setRegion:region animated:YES];




 //Annotation code will go here. Need help with that.
在u r.h文件中,获取AppDelegate引用

AppDelegate *appDelegate;
在ViewDidLoad方法中的.m文件中,在下面一行写下

appDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
并添加此行
[appdelegate.branch addObject:currentBranch]
;而不是
[self.branch addObject:currentBranch]


…现在您可以在应用程序中的任何位置使用此appdelegate.branch(Array)。

这可能会有帮助:您可以向我们显示您的阵列内容吗????那个数组中一定有字典。我添加了一些修改过的代码来填充数组。感谢您NSLog中的这些值看起来像您的值吗????我想您首先需要正确解析xml。@Smriti如果我这样做,如果我更改整数,我可以看到每个值。NSInteger指数=1;Mapdets*currentBranch=[[xmlParser branch]objectAtIndex:index];NSString*title=currentBranch.title;
appDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];