How to override a variable method in Objective-C

I am trying to extend a class with a variational method, for example:

- (void)someMethod:(id)arguments, ... ;

and in the subclass, override it by calling the original method, for example:

- (void)someMethod:(id)arguments, ... {
    [super someMethod:arguments, ...];

    // override implementation
    ...
}

but it does not work. Does anyone know how this works? Thank.

+5
source share
1 answer

similar to printf/ vprintf, the base would declare:

- (void)someMethod:(id)arguments, ... ;

a subclass will be implemented:

- (void)vsomeMethod:(id)arguments vaList:(va_list)vaList;

then the base will simply call vsomeMethod:vaList:in its implementation someMethod:vaList:.

+3
source

All Articles