8

今天早上升级到 8.3 后,我得到了这个主题的错误。

下面的代码曾经完美地工作,但它不再编译了。你们中的任何人都可以帮助我吗?

protocol CustomAccessoryProtocol {
    func controlButtonPressed(tag:Int)
}

class CustomAccessory : UIInputViewController {
    var accessoryView : UIView!
    var delegate : CustomAccessoryProtocol!

    @IBOutlet weak var returnButton: UIButton!
    @IBOutlet weak var backButton: UIButton!
    @IBOutlet weak var forwardButton: UIButton!

    init(delegate: CustomAccessoryProtocol){
        super.init()
        self.delegate = delegate
    }

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

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        let customNib = UINib(nibName: "CustomAccessory", bundle: nil)
        accessoryView = customNib.instantiateWithOwner(self, options: nil)[0] as! UIView
    }

    @IBAction func buttonPress(sender: AnyObject) {
        delegate.controlButtonPressed(sender.tag!)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(accessoryView)
    }
}
4

1 回答 1

7

我在使用 NSWindowController 的以下代码中遇到了同样的问题:

init() {
    super.init()
}

我将其更改为:

convenience init() {
    self.init()
}

我认为Apple比以前更严格地执行便利性。

于 2015-04-14T08:28:42.793 回答