8

I get the error in the subject after this morning's upgrade to 8.3.

The code below used to work perfectly, however it doesn't compile anymore. Can any of you please help me?

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)
    }
}
Jeremy Wiebe
  • 3,894
  • 22
  • 31
Razvan Soneriu
  • 587
  • 3
  • 7
  • 23
  • 1
    I wonder what the designated initializer for UIInputViewController? Not `init(frame: CGRect)` I presume. ? – clearlight Apr 09 '15 at 06:21
  • 1
    Isn't the first init a convenience init? Do you have to add convenience keyword to it? I don't have it down to a science. I've had some cases where I had to struggle with it for awhile to figure it out. Based on the initializers you *do* have, I assume you read the Swift [documentation](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html) on the subject at some point... – clearlight Apr 09 '15 at 06:23
  • 1
    Did anything change in the 8.3 docs for UIInputViewController or UIViewController? – clearlight Apr 09 '15 at 06:24
  • I can't find anything changed or maybe I'm missing something, I am also wondering about the designated initializer as all I can see are the ones that I already have. Maybe they will update the documentation as so far I cant see anything on this. Hoewever, it seems to work when adding convenience to the first init and self.init rather than super. You sir just made my day! – Razvan Soneriu Apr 09 '15 at 06:33

1 Answers1

7

I had the same problem on the following code with NSWindowController:

init() {
    super.init()
}

I changed it to:

convenience init() {
    self.init()
}

I'm thinking that Apple is enforcing convenience inits more strictly than before.

Joel B
  • 736
  • 7
  • 11