0

If I'm defining a view I need the following. What does the question mark in init?(coder aDecoder: NSCoder) mean?

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}
Ted Henry
  • 1,442
  • 1
  • 14
  • 34
  • 1
    It means it returns an optional. For instance if you have an "important" param in your init, and that param doesn't respects your needs, you might want to return nil instead of an instance that's not correct. – Larme Dec 05 '18 at 16:45
  • 4
    See "Failable Initializers" in the Swift Programming Language. https://docs.swift.org/swift-book/LanguageGuide/Initialization.html – Rob Napier Dec 05 '18 at 16:46

0 Answers0