"使用属性' nibName'在super.init之前的基础对象中初始化它"更新到Xcode 6.1后

时间:2014-10-21 22:57:18

标签: ios swift initialization xcode6.1

我的iOS应用程序中有这个代码,用Swift编写:

class AddHomeViewController: UITableViewController, UITextFieldDelegate
{
    ...

    required override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) 
    {
        super.init(nibName: nibName, bundle: nibBundle)
    }

更新到Xcode 6.1后,我在super.init(nibName: nibName, bundle: nibBundle)行上收到了这些错误。它之前运作得很好:

Use of property 'nibName' in base object before super.init initializes it

Use of property 'nibBundle' in base object before super.init initializes it

1 个答案:

答案 0 :(得分:6)

更改super.init()行以使用OrNil参数可解决问题:

super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)