Note that there are some explanatory texts on larger screens.

plurals
  1. PORelease message to a UINavigationController object
    primarykey
    data
    text
    <p>I am relatively new to Cocoa programming, and some aspects of memory managing are still troubling me. </p> <p>In this case, I am creating a UINavigationController using the alloc message, and initialising it with a UIView controller. Then, I am presenting the view modaly by passing it to the presentModalViewController method. Below is the code:</p> <pre><code>- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { NSLog(@"Tapped on disclosure button"); NewPropertyViewController *newProperty = [[NewPropertyViewController alloc] initWithDictionary]; newProperty.editProperty = [fetchedResultsController objectAtIndexPath:indexPath]; UINavigationController *newPropertyNavigationController = [[UINavigationController alloc] initWithRootViewController:newProperty]; [newProperty setPropertyDelegate:self]; [self presentModalViewController:newPropertyNavigationController animated:YES]; [newProperty release]; [newPropertyNavigationController release]; } </code></pre> <p>According to the retain count rules, if I send the message "alloc" to a class, an instance of that class is returned with retain count 1, and I am responsible for releasing it. In the above code, I release the newPropertyNavigationController instance after passing it to the modalViewController and presenting it. When I dismiss the modal view, the app crashes.</p> <p>If I comment out the last line, the app doesn't crash.</p> <p>Why is this happening? Is the particular alloc/init message to the UINavigationController working differently to the way it works in other classes, ie. is it perhaps returning an autoreleased instance?</p> <p>Thanks!</p> <p>Peter</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload