function with multiple arguments

后端 未结 4 1606
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 05:02

how to pass multiple arguments in a single function in Objective-C? I want to pass 2 integer values and the return value is also integer. I want to use the new Objective-C synta

4条回答
  •  抹茶落季
    2021-02-06 05:28

    Since this is still google-able and there are better solutions than the accepted answer; there's no need for the hideous withArg2 – just use colons:

    Declaration:

    @interface
    -(void) setValues: (int)v1 : (int)v2;
    

    Definition:

    @implementation
    -(void) setValues: (int)v1 : (int)v2 {
        //do something with v1 and v2
    }
    

提交回复
热议问题