• 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: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses?


  • Subject: Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses?
  • From: Jim Correia <email@hidden>
  • Date: Fri, 29 Jul 2005 07:36:22 -0400

On Jul 28, 2005, at 7:13 PM, Jim Hamilton wrote:

On Jul 28, 2005, at 5:01 PM, SA Dev wrote:

As Jim pointed out off-list, the docs state that subclasses specifically should *not* call super's +initialize. This is indeed strange. So does this mean that subclasses of NSObject shouldn't call super or *any* subclasses shouldn't call super? If the former, then any good documentation on someone's class should say whether or not super +initialize should be called which implies it's up to you to read it. If that's the case, then a disambiguation should be posted in the docs.

This one now has me stumped too (I haven't run into it myself and many of my classes register dependent keys). Thanks for the puzzle, Jim! :-)


Here's the answer:

<http://developer.apple.com/documentation/Cocoa/Reference/ Foundation/ObjC_classic/Classes/NSObject.html#//apple_ref/doc/uid/ 20000050-initialize>

Except it isn't.

The runtime docs also say that an initialize method shouldn't call super initialize.

<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ LanguageOverview/chapter_3_section_4.html#//apple_ref/doc/uid/ 20001424-87244>

Note: Remember that the runtime system sends initialize to each class
individually. Therefore, in a class’s implementation of the initialize
method, you must not send the initialize message to its superclass.


Given that, the documentation example which shows registration of dependent keys in the initialize method and my example from earlier today [1] the challenge is to implement an initialize on Person that registers the dependent key, and an implementation of [Employee initialize] which does not (because it does not, nor should it know, the inner workings of Person) register the dependent keys itself, or call [super initialize] in violation of the docs above.

How and when should dependent keys be registered in this case when there are subclasses. Either initialize is the wrong place, or you have to violate the rules laid out above.

[1] http://lists.apple.com/archives/cocoa-dev/2005/Jul/msg02292.html

Jim
_______________________________________________
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


  • Follow-Ups:
    • Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses?
      • From: Jim Hamilton <email@hidden>
    • Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses?
      • From: Pontus Ilbring <email@hidden>
References: 
 >Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses? (From: Jim Correia <email@hidden>)
 >Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses? (From: SA Dev <email@hidden>)
 >Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses? (From: Jim Correia <email@hidden>)
 >Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses? (From: SA Dev <email@hidden>)
 >Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses? (From: SA Dev <email@hidden>)
 >Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses? (From: Jim Hamilton <email@hidden>)

  • Prev by Date: Re: New looks [not] replacing Metal?
  • Next by Date: Re: binding with tranformer question
  • Previous by thread: Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses?
  • Next by thread: Re: Bindings clarification: +setKeys:triggerChangeNotificationsForDependentKey: doesn't affect subclasses?
  • Index(es):
    • Date
    • Thread