Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings: Where/when should dependent keys be registered? (when class with dependent keys is subclassed)



On 27 Jul 2005, at 7:37 PM, Jim Correia wrote:

The runtime system sends an initialize message to every class object
before the class receives any other messages and after its superclass
has received the initialize message. [...]
...

But more importantly:

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.

As I read it (and my experience does not contradict this), when you first use an Employee method, +initialize is sent to Employee, and serially to each member of its superclass chain, serially from the top superclass down. Members of the chain that don't implement +initialize pass their instance of the call up the inheritance chain, which can result in a superclass of such a class getting +initialize additional times.


So on first use of Employee, +initialize is sent to Person, and then to Employee (which if it doesn't implement +initialize, amounts to triggering Person's initialize on the instance [Employee class]).

    -- F

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Bindings: Where/when should dependent keys be registered? (when class with dependent keys is subclassed) (From: Jim Correia <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.