Re: NIB's owner doesn't get released because of NSArrayController
Re: NIB's owner doesn't get released because of NSArrayController
- Subject: Re: NIB's owner doesn't get released because of NSArrayController
- From: "Vitaly Ovchinnikov" <email@hidden>
- Date: Thu, 15 Jan 2009 20:11:04 +0300
Well, I got the idea and will try this. Just one question: do I miss
something when just releasing my two outlets to two top-level objects.
Your method is more common solution, but am I wrong with mine one? I
have only two objects in my NIB and release them both.
Thanks for help.
On Thu, Jan 15, 2009 at 7:40 PM, Keary Suska <email@hidden> wrote:
>
> 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 (email@hidden)
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:
This email sent to email@hidden