views:

19

answers:

1

I push a view controller into current navigation controller. It works fine, except when I am getting out of the current view controller, it crashes.

MyTableView *newPage = [[MyTableView alloc] initWithNibName:@"table2" bundle:nil];
[[self navigationController] pushViewController:newPage animated:YES];
//[newPage release];

I comment out the last line to prevent crash. I read another post about variables being over released. In the newPage, I only have one variable (arrCellText), and is initialized in the initWithNibName

NSArray *temp = [[NSArray alloc] initWithObjects:@"string1", @"string2", @"string3", nil];
[self setArrCellText: temp];
[temp release];

I put the release in the dealloc

[arrCellText release];

If I comment out setting and release of arrCellText, it works fine too. I must not have complete understanding of memory management, and I would like to understand this better. TIA

A: 

Where does the crash happen exactly? First you can release 'newPage' after pushing it onto the navigationController (because it's retained there).

You might try to access anything from newPage after coming back. 'newPage' was released in the mean time and thus has some garbage value (but not nil).

RupertP