views:

29

answers:

1

Hi,

I've defined a view controller with an array as one of its properties, and set the array with an allocated and autoreleased array. After I push the view for display I release it.

By watching the leaks tool I see that every time that I pop the view I suffer from leakage. I tried to release the properties explicitly, immediately after the push but the app crashes.

looking forward for your suggestions.

+1  A: 

The leak is probably because of the array property is set to retain, like so:

@property (nonatomic, retain) NSArray *yourArray;

Your autorelease object is retained on assignment to the yourArray property. Since it is retained, you have to release it in the controller's dealloc method:

- (void) dealloc {
   [yourArray release], yourArray = nil;
   [super dealloc];
}

HTH.

Alfons
WOW! So simple and I waisted hours on this.Thanks. you made me happy :-)
Tzur Gazit