Marking Unused Required Swift Initializers As Unavailable
However, if you do not use Interface Builder, then
init(coder:)
is irrelevant and will never be called. It is annoying boilerplate. But the real problem is that Xcode (and presumably other editors) will offerinit(coder:)
as an auto-complete option when initializing your view or view controller. That is not ideal, because it is not a valid way to initialize your custom view or view controller. Luckily, you can use Swift’s@available
attribute to prevent this, which also has the benefit of more clearly communicating that you should not use this initializer.
It’s annoying how each of my view and managed object subclasses has to reimplement a required
initializer that I never intend to call.