Re: class variables and class methods
Re: class variables and class methods
- Subject: Re: class variables and class methods
- From: "Louis C. Sacha" <email@hidden>
- Date: Wed, 7 Jan 2004 19:02:36 -0800
Hello...
One way to work around this problem would be to split your current
lookup method into two seperate methods, one that is overridden in
each subclass & a "designated" lookup method.
/* classTable and subClassTable are the two static variables */
@implementation ClassA
- (id)lookup
{
return [self lookupInTable:classTable];
}
- (id)lookupInTable:(id)table
{
/* your "lookup" code here, using the object passed in as the
argument, instead of accessing the static variable directly... */
}
@end
@implementation SubclassOfClassA
- (id)lookup
{
return [self lookupInTable:subClassTable];
}
@end
Hope that helps,
Louis
> If you need inheritance properties in class scope, do it using a class
accessor on the static variable, ie:
in .h file:
+ (int)myClassVariable;
in .m file:
static int myClassVariable = 0;
+ (int)myClassVariable {return myClassVariable;}
But this is the whole problem. If I then subclass this class and wish
myClassVariable to hold something different in the subclass but still
work with the inherited accessor / other methods, it won't. The
superclass's meClassVariable is used instead :(
Robert
---
GnuPG public key:
http://www.Far-Blue.co.uk
[demime 0.98b removed an attachment of type
application/pgp-signature which had a name of PGP.sig]
_______________________________________________
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.
_______________________________________________
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.