class variables and class methods
class variables and class methods
- Subject: class variables and class methods
- From: Robert Goldsmith <email@hidden>
- Date: Wed, 7 Jan 2004 22:15:27 +0000
Hi everyone :)
Sorry if this is a simple question but it has been driving me up the
wall :(
Maybe I was wrong to expect this but I thought class methods and class
variables would behave much like instance ones, but this does not seem
to be the case. Let me outline the problem:
Starting simple, I have class A, which has an instance method (lookup)
that refers to a static (so it won't inherit) class variable called
lookupTable (which is a c style array). Every instance of class A uses
the same lookup table. This works fine.
Now, I create a subclass of A called As and define a new static class
variable in As with the same name, lookupTable. When I call lookup in
an instance of As, I get back details from the lookupTable variable in
A, not the one in As.
Is there any easy way to fix this?
So far, I have found the only way is to access lookupTable via an
accessor method that must be repeated in every subclass of A. This is
not very good as it means repeating the accessor when, really, it
should just be inherited. On the other hand, at least the accessor is
small and not prone to have bugs in it :) It just seems very messy and
non oo :(
Thanks
Robert
---
GnuPG public key:
http://www.Far-Blue.co.uk/
_______________________________________________
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.