Un-requiring required initializers

I'm not a fan of this pitch. If I subclass UIView I would like to be reminded by a compiler that I am supposed to provide that init.

Notice that every hole-poking tool you mentioned is used in the place that doesn't fit. ! for unwrapping optionals is used when you are sure that value won't be nil, as! is used when you are sure cast won't fail, and try! is used when you are sure that the call won't throw. On the other hand required! would be used when someone, somewhere else may or may not write a subclass which may or may not support that init.

I would rather write the crashing line in the place that doesn't fit the type system, which is my broken subclass. And I think that typing fatalError is a good way to do that.

9 Likes