Re: accessing ivars in - (id)init
Re: accessing ivars in - (id)init
- Subject: Re: accessing ivars in - (id)init
- From: "Michael Ash" <email@hidden>
- Date: Sat, 10 Jan 2009 11:41:42 -0500
On Sat, Jan 10, 2009 at 12:09 AM, Kyle Sluder <email@hidden> wrote:
> On Fri, Jan 9, 2009 at 11:49 PM, Michael Ash <email@hidden> wrote:
>> Note that the problems, such as they are, with calling setters only
>> show up if your class is subclassed and the subclass does something
>> weird that doesn't like being called when the rest of the subclass
>> isn't initialized. If you're not subclassing your own class (or you
>> are but you aren't doing anything weird like this in it) then you are
>> perfectly safe.
>
> So what happens if Apple changes your superclass to observe itself?
> All of a sudden you start firing KVO notifications off when you didn't
> mean to.
Your superclass is fully initialized by this point. It should be able
to handle any KVO notifications arriving without any trouble.
Furthermore, if it's observing itself it's presumably because it wants
to know when the value changes. (That's the whole point of the thing,
after all.) Triggering the observer is therefore a *good* thing, and
bypassing it is likely to cause problems.
The problem isn't with superclasses, it's with subclasses. And they
only have a problem if they are behaving in a manner which, in my
opinion, is buggy. Opinions may vary there, but regardless of that,
the facts are that calling your superclass's setter is the right way
to do things.
Mike
_______________________________________________
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