Issues declaring already existing NSMutableArray in new class

Posted by Graeme on Stack Overflow See other posts from Stack Overflow or by Graeme
Published on 2010-06-13T09:48:54Z Indexed on 2010/06/13 9:52 UTC
Read the original article Hit count: 232

I have a class (DataImporter) which has the code to download an RSS feed. I also have a view and separate class (TableView) which displays the data in a UITableView and starts the parsing process, storing parsed information in an NSMutableArray (items) which is located in the (TableView) subclass.

Now I wish to add a UIMapView which displays the items in the (items) NSMutableArray. Herein lies the issue - I need to somehow get the data from the (items) NSMutableArray into the new (mapView) subclass which I'm struggling with - and I preferably don't want to have to create a new class to download the data again for the mapView class when it already is in the applications memory. Is there a way I can transfer the information from the NSMutableArray (items) class to the (mapView) class (i.e. how do I declare the NSMutableArray in the (mapView) class)?

Here's a overview of how the system works: App opened> Data downloaded (using DataImporter class) when (TableView) viewDidLoad runs> Data stored in NSMutableArray accessible by the (TableView) class> And from here I need to access and declare the array from a new (mapView) class.

Any help greatly appreciated, thanks.

Code for viewDidLoad MapKit:

Data *data = nil;
NSString *ilocation = [data locations];
NSString *ilocation2 = @"New Zealand";

NSString *inewlString;
inewlString = [ilocation stringByAppendingString:ilocation2];
NSLog(@"inewlString=%@",inewlString);

if(forwardGeocoder == nil)
{
    forwardGeocoder = [[BSForwardGeocoder alloc] initWithDelegate:self];
}   

// Forward geocode!
[forwardGeocoder findLocation: inewlString];

Code for parsing data into original NSMutable Array:

- (void)beginParsing {
    NSLog(@"Parsing has begun");
    //self.navigationItem.rightBarButtonItem.enabled = NO;
    // Allocate the array for song storage, or empty the results of previous parses
    if (incidents == nil) {
        NSLog(@"Grabbing array");
        self.datas = [NSMutableArray array];
    } else {
        [datas removeAllObjects];
        [self.tableView reloadData];
    }
    // Create the parser, set its delegate, and start it.
    self.parser = [[DataImporter alloc] init];      
    parser.delegate = self;
    [parser start];
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone-sdk