在Same View Controller中,我想使用自定义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]
后立即调用,为什么会这样?