On Jan 15, 2009, at 9:04 AM, Vitaly Ovchinnikov wrote:

I'll try to describe it again. I have NIB, NSObject-based owner of
this nib and NSView + NSArrayController in that NIB.
Let's name owner of this NIB MyViewController. It has -init and - dealloc methods

Basically, you have a classic retain cycle problem.

-(id) init
{
   self = [super init];
   [NSBundle loadNibNamed:@"MyView1" owner:self];

This method of loading a nib does not allow you to control top level objects. Use +loadNibFile:externalNameTable:withZone: or similar. See the Resource programming Guide, "Loading Nib Files into Your Program Programmatically", (locally: <file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapter_3_section_6.html#//apple_ref/doc/uid/10000051i-CH4-DontLinkElementID_12 >) for examples.

If you want to keep your current logic, your best bet is to have the owning window controller load the nib and manage the NSNibTopLevelObjects array. When you release pViewController, release the NSNibTopLevelObjects array. Although they won't all release immediately, everything should release at the next run loop cycle.

Alternatively, and I think this is a better way to go, don't bind anything to file's owner when you are loading nibs in this way. Instead, use outlets and/or intermediary controllers. Your sanity will thank you.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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