Message sent to deallocated object” after passing an instance to another View Controller?

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

Up vote 0 down vote favorite share g+ share fb share tw.

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; } } iphone ios iphone-sdk-4.0 uiviewcontroller uinavigationcontroller link|improve this question edited Sep 14 '11 at 9:21 asked Sep 14 '11 at 9:01Stephane Kouakou55318 98% accept rate.

Post your code where app is crashing – Nekto Sep 14 '11 at 9:03 1 A pure issue of memory leak. Will you please post some code? – iApple Sep 14 '11 at 9:04 could you show some code - otherwise it's hard to guess where the problem could be.

– pkyeck Sep 14 '11 at 9:04 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 Sep 14 '11 at 9:13.

You should make sure that the entries property of PropertiesMapViewController has the retain attribute: @property (nonatomic, retain) NSMutableArray * entries.

I declared it like this: @property (nonatomic,retain) NSMutableArray *entries; so pretty the same as you suggest – Stephane Kouakou Sep 14 '11 at 9:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions