ios - Release message to a UINavigationController object -


I'm relatively new to coco programming, and some aspects of memory management are still troubling me

In this case, I am creating a UINavigationController using AOL message, and starting it with a UIView controller. After that, I am presenting the visual modilla by sending it to the current Model Visual Control method. Below is the code:

  - (zero) table view: (UITableView *) tableview assistant boxTotPowerWorvindexpath: (NSIndexPath *) indexing path {nslog ("tap on disclosure button"); NewPropertyViewController * newProperty = [[NewPropitView Controller Alok] initWithDictionary]; NewProperty.editProperty = [fetchedResultsController objectAtpand: indexpath]; UINavigationController * newPropertyNavigationController = [[UINavigationController alloc] initWithRootViewController: newProperty]; [New Property Setgift Deliaget: Self]; [Self-Present Model View Controller: Animated New Property Controller Controller: Yes]; [New property release]; [Newprotecting controller release]; }  

If I send an "alloc" message to a class, then an example of that category returns with a counting number 1, and I am responsible for issuing it. In the above code, I issue this new property navigation controller example after passing it to modalViewController and presenting it. When I dismiss the modal view, the app crashes.

If I comment on the last line, then the app does not crash.

Why is this happening? Special assignment / init message works differently for UIAV controller in the way it works in other classes. Is it perhaps returning an autorealed example?

Thank you!

Peter

The way you make a modal view controller looks right .

If you are removing memory incorrectly, it will let you know that when you leave the modal view controller you get only an error. / P>

For reference I think the following use of autorelease is more readable and maintained.

NewPropertyViewController * newProperty = [[[NewPropertyViewController alloc] initWithDictionary] autorelease]; NewProperty.editProperty = [fetchedResultsController objectAtpand: indexpath]; UINavigationController * newPropertyNavigationController = [[[UINavigationController alloc] initWithRootViewController: newProperty] autorelease]; [New Property Setgift Deliaget: Self]; [Self-Present Model View Controller: Animated New Property Controller Controller: Yes];

Comments