objective-C ... 语法,



 -(instancetype)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...
{
    self = [super init];
    if (self) {

        NSLog(@"%@",otherButtonTitles);
    }
    return self;
}

代码如上,如何拿到otherButtonTitles的列表

ios objective-c

第十一只尾兽 9 years, 3 months ago

google 可变参数

cdqclq answered 9 years, 3 months ago


 for (NSString *title in otherButtonTitles){
    //这样子试试,swift是这么写的
}

ROSARIN answered 9 years, 3 months ago

解决了


 id eachTitle;
        va_list args;
        if (otherButtonTitles) {
            [self.buttonTitles addObject:otherButtonTitles];
            va_start(args, otherButtonTitles);
            while ((eachTitle = va_arg(args, id))) {
                [self.buttonTitles addObject:eachTitle];
                va_end(args);
            }
        }

轻飘飘的爱恋 answered 9 years, 3 months ago

Your Answer