tags:

views:

115

answers:

2

Hi, I have this:

-(NSDictionary *)properties;
+(NSDictionary *)ClassProperties;

Now, how can I call ClassProperties from sub-classes?

-(NSDictionary *)properties {
    return [? ClassProperties];
}

The point is that ClassProperties gets the list of properties in the class, so i can't call the base class definition.

+1  A: 

You can just use the class name of the subclass.

Marc Charbonneau
+3  A: 

Along the lines of Marc's response, you could more generally call the method with

[[self class] ClassProperties]

In fact, if your base class and all the subclasses implement + (NSDictionary *)ClassProperties, then your base class can do this

- (NSDictionary *)properties {
    return [[self class] ClassProperties];
}

and then none of your subclasses will need to know about - (NSDictionary *)properties. The correct class method would be called based on what self is.

zbrimhall