问题
I'm trying to extend a class that has a variadic method such as:
- (void)someMethod:(id)arguments, ... ;
and in the subclass override it by calling the original method like:
- (void)someMethod:(id)arguments, ... {
[super someMethod:arguments, ...];
// override implementation
...
}
but this doesn't work. Anyone know how to work this? Thanks.
回答1:
similar to printf
/vprintf
, the base would declare:
- (void)someMethod:(id)arguments, ... ;
the subclass would implement:
- (void)vsomeMethod:(id)arguments vaList:(va_list)vaList;
then the base would just call vsomeMethod:vaList:
in its implementation of someMethod:vaList:
.
来源:https://stackoverflow.com/questions/9562361/how-to-override-a-variadic-method-in-objective-c