I release outlets in -dealloc that gets called after I removed array controller's binding to it. I checked this with NSLog() calls and by breakpoint - it works. I release my outlets there and they seems to be deallocated too (I checked for NSView, but it seems array controller works the same way).
I just want to make sure that I don't need to release something else that I loaded with NIB. On Thu, Jan 15, 2009 at 8:42 PM, Keary Suska <cocoa-...@esoteritech.com> wrote: > > On Jan 15, 2009, at 10:11 AM, Vitaly Ovchinnikov wrote: > >> 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. > > That approach may be OK, but it seems to me to violate "good" programming > practices. Among them: memory management rules, not being self-documenting, > and not being future-proof. Besides, when do you release the outlets? The > file's owner dealloc will never get called, so you can't do it there. The > window controller can't have outlets to those objects, so... > >> On Thu, Jan 15, 2009 at 7:40 PM, Keary Suska <cocoa-...@esoteritech.com> >> 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. >>> > > > 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