Swift中的UIViewController初始化会引发编译错误

时间:2014-06-07 10:24:01

标签: swift

我试图使用指定的初始化程序和xib文件View.xib实例化UIViewController,如此

var appBundle = NSBundle.mainBundle()
var controller = UIViewController.init(nibName: "View", bundle: appBundle)

但是我得到了编译错误:

Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254

是否有其他人收到此错误?我不知道自己做错了什么。

1 个答案:

答案 0 :(得分:2)

试试这个:

var appBundle = NSBundle.mainBundle()
var controller = UIViewController(nibName: "ViewController", bundle: appBundle)