On Feb 11, 2010, at 9:03 AM, Gordon Apple wrote:
> It's unfortunate that all initializers don't at least call "init"
> internally.  That would make subclassing easier if all one needs is to set a
> few ivars.  In the earlier days of MacApp (Pascal and first C++ versions)
> there was a basic initializer, similar to "init", called by all classes,
> just for that purpose.  Of course, Objective C at least sets them all to
> zero, reducing the need -- but it still would have been useful, sometimes
> eliminating the need to override multiple initializers.

The designated initializer pattern solves the problem in a similar way. Every 
initializer in a class is expected to call through that class's designated 
initializer eventually. When you subclass a class, you can override just the 
designated initializer to do your work and then call super's designated 
initializer. All of the superclass's other initializers will funnel through 
your code without any additional overrides.


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to