I've a NSMutableArray containing instances of my model class called PropertyData (only properties and no methods). In my app, there is a "View on map" button which when tapped set this NSMutableArray in the property of the Map View Controller before pushing its view on top of the navigation. The Map View controller successfully received this array (with NSLOG I printed out the total items received in the map view controller) but when looping through it I got this error:
[PropertyData lat] message sent to deallocated instance
Any idea why ?
Thx for helping,
Stephane
P.S:
In the first view controller data are stored to an ivar (declared as a NSMutableArray property in interface and then synthesize) called rqst_entries and here's how it switches to Map view:
-(void)show_map
{
PropertiesMapViewController *pMapView = [[PropertiesMapViewController alloc] init];
pMapView.entries = self.rqst_entries; // pMapView.entries is alsi a NSMutableArray
[self.navigationController pushViewController:pMapView animated:YES];
}
Here is the code where it crashes:
if(self.entries != nil)
{
NSLog(@"received items count=%d",[self.entries count]);
NSNumberFormater *nf = [[NSNumberFormater alloc] init];
for(PropertyData *property_data in self.entries)
{
if(property_data==nil) continue;
[nf setNumberStyle:NSNumberFormatterDecimalStyle];
// CRASH OCCURS HERE:
NSNumber *lat = [nf numberFromString:property_data.lat];
}
}