在 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]
,为什么会这样?