Re: Retained Outlet
Re: Retained Outlet
- Subject: Re: Retained Outlet
- From: Richard Somers <email@hidden>
- Date: Fri, 18 Nov 2011 15:57:56 -0700
On Nov 18, 2011, at 9:23 AM, Richard Somers wrote:
> The normal pattern for Interface Builder Outlets is assign but I have an outlet that must be retained to work corectly. The outlet is not in File's Owner but is in a custom view in a window.
>
> // Interface
> @property (retain) IBOutlet NSArrayController *myController;
>
> // Implementation
> @synthesize myController = _myController
>
> The application runs fine with no memory leaks reported by Instruments so I assume that the frameworks are releasing myController.
SOLVED - Mac OS X Retained Outlet
Thanks for everyones comments. Here is what I have learned.
The frameworks will not release a retained outlet (assuming top-level objects are handled correctly). You are responsible for releasing it. A retained outlet is considered ownership and so you must release it.
If you do not release it, it will be alive in memory even though Instruments may not report it as a leak. For my particular case the outlet was actually a subclass of NSArrayController. Instruments reports the responsible caller as -[NSClassSwapper initWithCoder:]. I am not an expert in leaks but it appears that a reference to the outlet is maintained by the frameworks until the outlet is fully released and so Instruments does not report it as a leak.
--Richard
_______________________________________________
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