how to pass variable arguments to another method?

前端 未结 4 1343
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 05:47

i have googled and came to know that how to use the variable arguments. but i want to pass my variable arguments to another method. i m getting errors. how to do that ?

4条回答
  •  一向
    一向 (楼主)
    2020-11-30 05:54

    I think you could use macros to achieve same thing. Let's say you wanna pass aMethod's variable arguments to another

    -(void) aMethod:(NSString *) a, ... {
    }
    

    You could define your another 'method' using macro though it is not a real method:

    #define anotherMethod(_a_,...) [self aMethod:_a_,##__VA_ARGS__]
    

    This is my solution.

提交回复
热议问题