Reputation: 1430
I have filled a NSMutablearray with Objects from my XML praser. I now what to use that to populate for my Map Annotations. I have this Array working for my Table which brings the objects into the cell, but I want to use the same NSMutablearray for my map.
//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.
Ok So this is where i'm at. I have that array filled with objects that is filled with Title, subtile, Latitude, Longitude, i want to basically xpolde that array and use the elements.
Thanks for the help.
My array is filled as such if i run NSLog(@"%@", currentBranch);
2013-02-28 07:53:53.537 SAMPLE[13642:207] (
"<Mapdets: 0x754d3b0>",
"<Mapdets: 0x754d5c0>",
"<Mapdets: 0x754d710>"
)
And in my XMLpraser file i fill it like this.
- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if (isStatues)
{
if ([elementname isEqualToString:@"title"])
{
currentBranch.title = currentNodeContent;
}
if ([elementname isEqualToString:@"street_address"])
{
currentBranch.subtitle = currentNodeContent;
}
if ([elementname isEqualToString:@"lng"])
{
currentBranch.lng = currentNodeContent;
}
if ([elementname isEqualToString:@"lat"])
{
currentBranch.lat = currentNodeContent;
}
}
if ([elementname isEqualToString:@"branch"])
{
[self.branch addObject:currentBranch];
currentBranch = nil;
currentNodeContent = nil;
This is all working, I just want to now use this NSMutablearray in another class for my map.
Upvotes: 3
Views: 185
Reputation: 452
Take Branch(NSMutableArray
) in Appdelegate and
In u r .h file take AppDelegate reference
AppDelegate *appDelegate;
and in .m file In ViewDidLoad Method write this below line
appDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
and add this line [appdelegate.branch addObject:currentBranch]
; instead of [self.branch addObject:currentBranch]
;
...now u can use this appdelegate.branch(Array) any where in u r App.
Upvotes: 1