美文网首页
NS_REQUIRES_NIL_TERMINATION NS_

NS_REQUIRES_NIL_TERMINATION NS_

作者: 光头金项链的和尚 | 来源:发表于2016-11-23 10:57 被阅读63次

    要自定义一个alertView 去看原生的api 不想传字符串数组,想像他一样传多个NSString,然后接口写好如何取不会了,查资料 发现了这个 留存
    https://developer.apple.com/library/content/qa/qa1405/_index.html

    我这块的代码

    - (instancetype)initWithTitle:(NSString *)titles andImage:(UIImage *)promptImage cancleButton:(NSString *)cancleButton otherButtons:(NSString *)otherButtons, ...
    {
        if (self = [super init]) {
            self.alertTitle = titles;
            self.promptImage = promptImage;
            self.cancleButtonTitle = cancleButton;
            NSMutableArray *otherBtnsArr = [[NSMutableArray alloc] init];
            id eachObject;
            va_list argumentList;
            if (otherButtons) // The first argument isn't part of the varargs list,
            {                                   // so we'll handle it separately.
                [otherBtnsArr addObject: otherButtons];
                va_start(argumentList, otherButtons); // Start scanning for arguments after firstObject.
                while ((eachObject = va_arg(argumentList, id))) // As many times as we can get an argument of type "id"
                    [otherBtnsArr addObject: eachObject]; // that isn't nil, add it to self's contents.
                va_end(argumentList);
            }
            NSLog(@"%@",otherBtnsArr);
        }
        return self;
    }
    

    相关文章

      网友评论

          本文标题: NS_REQUIRES_NIL_TERMINATION NS_

          本文链接:https://www.haomeiwen.com/subject/vwzmpttx.html