Variable length parameters in Objective-C

前端 未结 3 1695
我在风中等你
我在风中等你 2021-01-07 03:55

How can i make a class method with variable length parameters, in Objective-C?

For example, a method like -arrayWithObjects:

NSArray *array = [NSArra         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-07 04:25

    Methods that take variable arguments are known as variadic methods. The "..." is the variable argument.
    For example, your function declaration would be: - (void)specialWithX:(NSInteger)x y:(NSInteger)y, ...;

    For additional information take a look at Variable argument lists in Cocoa

提交回复
热议问题