0
votes

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]; 
   }

}
1
Post your code where app is crashingNekto
A pure issue of memory leak. Will you please post some code?alloc_iNit
could you show some code - otherwise it's hard to guess where the problem could be.Philipp Kyeck
What property type have you declared for the mutable Array in Map View Controller ?Since you are setting it from some other view have you retailed the received array from previous view.Rahul Sharma

1 Answers

1
votes

You should make sure that the entries property of PropertiesMapViewController has the retain attribute:

@property (nonatomic, retain) NSMutableArray * entries;