is protected broken, or am I?
is protected broken, or am I?
- Subject: is protected broken, or am I?
- From: Matt Neuburg <email@hidden>
- Date: Thu, 10 Oct 2002 12:23:25 -0700
According to the docs, @protected means "The instance variable is
accessible within the class that declares it and within classes that
inherit it."
MyClass is a class with an ivar myIvar. MySubClass is a subclass of
MyClass. myClassInstance and mySubClassInstance are instances of these two
classes, respectively. mySubClassInstance has a reference to
myClassInstance. In MySubClass, I say this:
[myClassInstance->myIvar doStuff];
And the compiler slaps my hand, saying: "instance variable `myIvar' is
declared protected".
Now, I went to some trouble to make MySubClass a subclass of MyClass
exactly so mySubClassInstance would be able to get at myClassInstance's
ivars. Now it appears I can't. I'd rather not make MyClass's ivars @public,
though I will if I have to. But before I do, I'd like to know why this
didn't work. Is it that @protected means I have access to my copy of an
ivar but not to my super's copy of that ivar? (If so, I think the
above-quoted sentence needs rewriting, since "the instance variable" turns
out to be ambiguous.)
Is there perhaps a better way to do what I'm trying to do? MyClass is all
set up in IB with dozens and dozens of outlets connected, and I want to
take advantage of those directly from within MySubClass without having to
write accessors. The idea of MySubClass is to take advantage of most of
MyClass's functionality and just about all of its outlets as set in IB,
while altering some functionality. m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.