Swift中的自定义Init ViewController

时间:2014-12-08 09:31:09

标签: swift uiviewcontroller init


我在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];

0 个答案:

没有答案