Hi this is a follow up question on memory management. In my class 
BrowseViewController, I have a UITableView and 2 NSMutableArrays.

@interface BrowseViewController : UIViewController <UIActionSheetDelegate> {
        IBOutlet UITableView *tableView;
        NSMutableArray *tableList;
        NSMutableArray *cfrTitleList; 
}
@property(nonatomic, retain) UITableView *tableView;

@end

Now the BrowseViewController has a few "child" Navigational controllers. This 
allows the user to drill down. My question is, in the BrowseViewController.m 
dealloc method, if I release the two NSMutableArrays, I receive the error 
“EXC_BAD_ACCESS”. If I don't release the NSMutableArrays, does this mean the 
navigationController takes ownership of the NSMutableArrays?

Thanks for all the help.

Phil
 

On Jan 17, 2010, at 6:44 AM, Philip Vallone wrote:

> Thanks Tom. Great explanation!
> 
> 
> On Jan 17, 2010, at 6:05 AM, Tom Davie wrote:
> 
>> Yes, that code is 100% fine.
>> 
>> Here's the logic from purely your point of view.
>> 
>> You allocate browserviewController and in doing so take ownership.
>> You do some stuff with browserviewController.
>> You are finished with browserviewController, and don't want to do anything 
>> else with it, so you resign ownership.
>> 
>> From a more global perspective, the navigationController becomes interested 
>> in browserviewController when you ask it to push it, and it too takes 
>> ownership, so when *you* release, the navigationController still has a 
>> handle on the controller, and keeps hold of it until it decides it's done 
>> with it.
>> 
>> Bob
>> 
>> On Sun, Jan 17, 2010 at 10:30 AM, Philip Vallone 
>> <philip.vall...@verizon.net> wrote:
>> 
>> Hi,
>> 
>> I have Navigation based application. When I switch from one view to the next 
>> I use the following code. In the below code, is it ok to release 
>> "browseviewController"?
>> 
>> 
>> BrowseViewController *browseviewController = [[BrowseViewController alloc] 
>> initWithNibName:@"BrowseViewController" bundle:nil];
>> [browseviewController setTitle:@"Browse By Title"];
>> [self.navigationController pushViewController:browseviewController 
>> animated:YES];
>> // ok to release?
>> [browseviewController release];
>> 
>> 
>> Thanks,
>> 
>> Phil_______________________________________________
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com
>> 
>> This email sent to tom.da...@gmail.com
>> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/philip.vallone%40verizon.net
> 
> This email sent to philip.vall...@verizon.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to