Re: is protected broken, or am I?
Re: is protected broken, or am I?
- Subject: Re: is protected broken, or am I?
- From: Brent Gulanowski <email@hidden>
- Date: Fri, 11 Oct 2002 11:39:16 -0400
On Thursday, October 10, 2002, at 06:42 PM, matt neuburg wrote:
My idea was that I would connect the MySubClass instance to the
MyClass instance, and then the MySubClass instance could see the
window connections by way of the MyClass instance (because this is
what I thought "protected" meant), and would also inherit the same
functionality (because it's a subclass) and so would be able to keep
what was applicable and override what was not.
Why can you not just initialize the subclass instance with the same
ivar values that are in the MyClass instance? The subclass has all the
ivars of the superclass and any new ones that you add. Or does the
subclass instance in question have to muck about with more than one
instance of the superclass? In which case, I suspect that you should
have a controller object doing the work, be it a delegate or otherwise,
and the ivars should be in there, not in MyClass or MySubClass at all.
The central idea of objects is that they cannot get into each others'
ivars, even if they are of the exact same class. The exception to this
is the friend construct in C++, and whatever it is you're saying
REALBasic allows, where a declared friend class instance can read ivars
of instances of the class in question. Objective-C doesn't allow this,
prefering that you always use accessors. Is using accessors to get ivar
values so much of a pain? Or do you have religious objections? Saying
"I can do it in another language" is not a good argument.
The pattern that's becoming apparent is that, instead of learning how
things are done in Objective-C, you are bringing your own concepts to
the language and trying to make them work, then blaming the language
when you can't. That is self-defeating. It is also why everyone is
confused by your questions. They are alien to the design of the
language and environment that their thinking automatically assumes when
answering questions on a list like this.
Cheers,
--
Brent Gulanowski email@hidden
"We've heard that a million monkeys at a million keyboards could
produce the Complete Works of Shakespeare; now, thanks to the Internet,
we know this is not true." -- Robert Wilensky
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.