0

在 SomeViewController 中,我想使用自定义的 init 方法,同时禁用-initWithNibName:bundle:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    NSAssert(NO, @"use -initWithChannel:tag: instead");
    return nil;
}

- (instancetype)initWithChannel:(NSString *)channel tag:(NSString *)tag
{
    if (self = [super init]) {
        self.channel = channel;
        self.tag = tag;
    }
    return self;
}

但是当我打电话时-initWithChannel:tag:-initWithNibName:bundle:马上就打电话-[UIViewController init],为什么会这样?

4

1 回答 1

1

当你调用你的调用[super init]时初始化。见这里UIViewControllerinitWithNibName

于 2013-10-12T07:51:45.680 回答