我在obj-c
中有代码+(id)viewController
{
UIViewController *vc = [[self alloc]init];
return vc;
}
但是我不能用swift代码重现这个,我试试这种方式
class func viewController()->UIViewController
{
return self();
}
convenience override init () {
var nibName = NSStringFromClass(self.dynamicType) // In this part I get err
self.init(nibName:nibName,bundle:nil);
}
我无法在init之前获得自我类名...在obj-c中看起来像这样
NSString *nibName = NSStringFromClass([self class]);
self = [super initWithNibName:nibName bundle:nil];