iOS自定义多变量函数,如何获取多变量

Posted 阿曌

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS自定义多变量函数,如何获取多变量相关的知识,希望对你有一定的参考价值。

- (instancetype)initWithTitle:otherButtonTitles, ... 
    NSMutableArray *buttonTitleArray = [NSMutableArray array];
    va_list args;
    va_start(args, otherButtonTitles);
    if (otherButtonTitles) 
        [buttonTitleArray addObject:otherButtonTitles];
        while (1) 
            NSString *otherButtonTitle = va_arg(args, NSString *);
            if (otherButtonTitle == nil) 
                break;
             else 
                [buttonTitleArray addObject:otherButtonTitle];
            
        
    
    va_end(args);

    //...后面略

如代码,定义时加上...,这个写法可以参照UIActionSheet的初始化呀。
用的时候使用va_list循环获取。没去深究,就先记着这么用吧=。=

以上是关于iOS自定义多变量函数,如何获取多变量的主要内容,如果未能解决你的问题,请参考以下文章