<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">It seems like having a protocol restricted to instances of ‘<font face="Helvetica Neue" class="">AccountAuthorizationController’ (as Brent suggested) would solve your problem, wouldn’t it?</font></div><div class=""><font face="Helvetica Neue" class=""><br class=""></font></div><div class=""><font face="Helvetica Neue" class="">You could just add all method declarations that are supposed to be abstract to that protocol instead, and then make sure your subclasses implement the protocol - which means the compiler forces them to implement the abstract methods.</font></div><div class=""><br class=""></div>
> Currently I have in a private framework a class named `AccountAuthorizationController` with subclasses like `OAuthAccountAuthorizationController`, `OAuth2AccountAuthorizationController` and `WebFormAccountAuthorizationController` and so on.<br class="">> <br class="">> In the root "abstract" class I have methods without implementation where I have to use `fatalError()` to ensure that they will never been called. I cannot prevent the framework user to instantiate the `AccountAuthorizationController`, however.<br class="">> <br class="">> Look that this is only one example. I have other cases as well when I'd like to have abstract classes and abstract methods.<br class="">> <br class="">> I know that structs and protocols are "elegant, simple and powerful" (as they seem to be all new frameworks and languages that pop up every day on the Internet) and the argumentsin favor of composition rather than inheritance. But I still would like to take advantage of the decades of available knowledge in object orientation in my projects.<br class="">> <br class="">> +1 for abstract classes and abstract methods.<br class="">> <br class="">> -Van<br class="">> <br class="">> On Fri, Feb 26, 2016 at 12:46 PM, Evan Maloney via swift-evolution<<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>(<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>)>wrote:<br class="">> > >Well not exactly, if you want the same behaviors in subclasses of UIViewController and UITableViewController :<br class="">> > >- with protocols + extensions, you write in once and apply it to each of your subclasses<br class="">> > >- with abstract classes you have to write 2 abstract classes, one for direct UIViewController subclasses, one for UITableViewController subclasses<br class="">> > <br class="">> > That's a problem with class hierarchies in general, not with abstract classes.<br class="">> > <br class="">> > You can use the same argument to call for the removal of classes from Swift, which is why I think the fundamental question is, are classes intended to be first-class citizens in Swift?<br class="">> > _______________________________________________<br class="">> > swift-evolution mailing list<br class="">> > <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>(<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>)<br class="">> > <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">> <br class="">> <br class="">><span class="Apple-converted-space"> </span>
</body></html>