你好!我想为我的类创建构造函数,我有一个错误:在从初始化程序swift返回之前,不会在所有路径上调用Super.init

时间:2022-02-04 19:20:52

I want to create constructor for my class and I have an error:

我想为我的类创建构造函数,我有一个错误:

Super.init isn't called on all paths before returning from initializer swift.

在从初始化程序swift返回之前,不会在所有路径上调用Super.init。


class MyPicker: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSource {

    var pickerContent: [String] = [""]
    var textField = UITextField()

    var form: Form!

    init(form: Form, content: [String]) {
        self.form = form
        self.pickerContent = content
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

1 个解决方案

#1


1  

Add

super.init(frame: CGRectZero)

in your init, class need to init it's super class

在你的init中,类需要初始化它的超类

#1


1  

Add

super.init(frame: CGRectZero)

in your init, class need to init it's super class

在你的init中,类需要初始化它的超类