• 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: accessing ivars in - (id)init
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: accessing ivars in - (id)init


  • Subject: Re: accessing ivars in - (id)init
  • From: Quincey Morris <email@hidden>
  • Date: Fri, 9 Jan 2009 21:31:02 -0800

This discussion can backwards and forwards on the issue of ivars vs accessors, but it won't get anywhere definitive, because there is no answer that covers all cases.

All we've got is that Apple's currently recommended practice is to avoid accessors in initializers. Clear, but not absolute.

On Jan 9, 2009, at 21:09, Kyle Sluder wrote:

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.

It seems to me that would be a bug in the superclass. An object can't safely start observing itself in its initializer, because until the *original* initializer returns (i.e. the bottom-most subclass initializer), the address of 'self' is not irrevocably determined (any intermediate initializer can theoretically return a different object).



_______________________________________________

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


References: 
 >accessing ivars in - (id)init (From: Ron Fleckner <email@hidden>)
 >Re: accessing ivars in - (id)init (From: "Michael Ash" <email@hidden>)
 >Re: accessing ivars in - (id)init (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Re: accessing ivars in - (id)init
  • Next by Date: Re: [commentary] The value of warnings [was: Re: A Data Object in Cocoa]
  • Previous by thread: Re: accessing ivars in - (id)init
  • Next by thread: Re: accessing ivars in - (id)init
  • Index(es):
    • Date
    • Thread