how to pass variable arguments to another method?

前端 未结 4 1341
没有蜡笔的小新
没有蜡笔的小新 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 06:02

    Have you considered setting up your arguments in either an array or dictionary, and coding conditionally?

    -(void) aMethodWithArguments:(NSArray *)arguments {
        for (id *object in arguments) {
            if ([object isKindOfClass:fooClass]) {
                //handler for objects that are foo
                [self anotherMethod:object];
            }
            if ([object isKindOfClass:barClass]) {
                //and so on...
                [self yetAnotherMethod:object];
            }
        }
    }
    

提交回复
热议问题