Re: Re: Should I retain/release IBOutlet?
Re: Re: Should I retain/release IBOutlet?
- Subject: Re: Re: Should I retain/release IBOutlet?
- From: Eric <email@hidden>
- Date: Wed, 17 May 2006 13:02:59 -0700
Thanks, this is what I needed. So I can kind of consider IBOutlet to be a
type of weak reference.
On 5/17/06, Julien Jalon <email@hidden> wrote:
When loading a nib, you should consider that it's like if "file owner"
allocated and "owns" responsibility to release top-level objects only,
so "file owner" does not need to retain them an extra time but will
have to release them when needed.
object -> object IBOutlet link does not suppose any retain-release. If
you have a top-level object instantiated by the nib-loading linked to
an other object using IBOutlet, this top-level object is not
considered having any ownership to that other object so does not need
to release it.
Nobody can answer your question "If my custom controller class
contains IBOutlet to other objects in the nib (like UI element), should
the
custom controller retain its IBOutlets" as we don't know what the
relationship between your controller and that UI element is meant to
be. If you consider that the controller needs ownership to that
element, you need to add an extra retain after nib-loading ensuring
that your controller will prevent the element to be deallocated
without its consent.
When working on retain/release, always think in terms of "ownership".
IBOutlet does not imply any ownership.
--
Julien
On 5/17/06, Eric <email@hidden> wrote:
> Sorry I don't mean to bother you.. but I've read through all the
documents
> referred to by Bill twice and still could not find the answer to my
> question. Could you point me to where in the documentation is my
question
> answered? There is nothing specifically stating whether I should
manually
> retain objects loading from a NIB.
>
> On 5/17/06, mmalcolm crawford <email@hidden> wrote:
> >
> >
> > On May 17, 2006, at 9:46 AM, Eric wrote:
> >
> > > However, I'm not so concerned with when or
> > > who to release the objects in the nib as to whether one should
> > > retain them.
> > > For example, if I have a nib with a file owner, and another
> > > placeholder
> > > object like a custom controller class. If my custom controller
class
> > > contains IBOutlet to other objects in the nib (like UI element),
> > > should the
> > > custom controller retain its IBOutlets? Or should the controller
just
> > > assume the objects will be retained by the file's owner?
> > >
> > Again, this is answered in the documentation...
> >
> > mmalc
> >
> >
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden