Hi, Thanks for the reply.

In AppController.h I have an ivar:
Volume *selectedPTVolume;

In a method in AppController, I have the following:
NSMutableDictionary *data = [partitionListDictArray objectAtIndex: [tableViewPTList selectedRow]];
selectedPTVolume = [[Volume alloc] initWithDictionary:data];
[selectedPTVolume retain];// if I comment this the GUI hangs, selectedPTVolume contains an ivar HDIR *dirRoot; which is passed as the root item of an outline view. dirRoot has an mutable array, which contains other HDIR objects as its children and so on a tree is formed.

In a method, where I need to release selectedPTVolume, I have:
if (selectedPTVolume)
{
volumeScanType = [selectedPTVolume volumeScanType];// selectedPTVolume retainCount = 2 here
        [selectedPTVolume release];
        [selectedPTVolume release];// selectedPTVolume retainCount = 1 here
selectedPTVolume = nil;// selectedPTVolume retainCount = 0 here and sometimes still shows as 1 while debugging.
        if (outlineViewData)
                [outlineViewData reloadData];/ crashes here
}

Releasing selectedPTVolume also releases HDIR *dirRoot.

Wishes,
Nick


On 10-Oct-2009, at 4:06 PM, Graham Cox wrote:


On 10/10/2009, at 9:31 PM, Nick Rogers wrote:

Shall I get its retainCount and then release it that many times?


For heavens' sake, NO!

Ignore retain counts. They are not reliable evidence of anything you can use. Instead, just follow the rules:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html

I'm doing alloc and initWithDictionary to get an instance of Volume.
I have to do [selectedPTVolume retain]; when allocing to get it to work properly.

Show your code. This sounds wrong, but without seeing the code it can't really be inferred from the description.




--Graham



_______________________________________________

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