• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Retained Outlet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retained Outlet


  • Subject: Re: Retained Outlet
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 18 Nov 2011 11:42:17 -0800

On Fri, Nov 18, 2011 at 11:22 AM, Richard Somers
<email@hidden> wrote:
> The outlet in question is in a custom class and requires a setter with retain semantics. NSWindowController will use this setter for the outlet when loading the nib.

NSWindowController does not call your setter. NSNib does.

>
> Object ownership policy seems a little blurry here. Normally a class will initialize its ivars and then cleanup in dealloc. But the custom class never initializes the outlet. The nib loading machinery initialize the outlet.
>
> So that may mean NSWindowController knows that the outlet has retain semantics and will set the outlet to nil when releasing top-level objects. If not then the class should release the outlet in its dealloc method. I am confused, which one is it?

It means that NSWindowController will balance NSNib's extra -retain.
It doesn't balance the additional -retain from calling your setter.

Think about it this way: NSWindowController loads your nib using
-[NSNib instantiateNibWithOwner:topLevelObjects:]. It takes
responsibility for calling -release on all of the top-level objects it
gets back from this method call.
-instantiateNibWithOwner:topLevelObjects: does the magic of hooking up
outlets; part of that magic involves calling your setters if it finds
them. NSWindowController is entirely unaware of that process.

--Kyle Sluder
_______________________________________________

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

  • Follow-Ups:
    • Re: Retained Outlet
      • From: Richard Somers <email@hidden>
References: 
 >Retained Outlet (From: Richard Somers <email@hidden>)
 >Re: Retained Outlet (From: Kyle Sluder <email@hidden>)
 >Re: Retained Outlet (From: Richard Somers <email@hidden>)

  • Prev by Date: Re: Retained Outlet
  • Next by Date: Re: Retained Outlet
  • Previous by thread: Re: Retained Outlet
  • Next by thread: Re: Retained Outlet
  • Index(es):
    • Date
    • Thread