title: Abstract methods in Swift?
body: <p>I have few questions for Swift developers regarding the concept of abstract classes.</p>
  
  <ol>
  <li><strong>How do you define an abstract class in Swift?</strong> Is there any way to prevent a class from being instantiated, while providing an initializer for its subclasses to use?</li>
  <li><strong>How do you define abstract methods, while implementing others?</strong> When defining abstract methods, Apple generally points you to protocols (interfaces). But they only solve the first part of my question, since <em>all</em> of the methods they define are abstract. What do you do when you want to have both abstract and non-abstract methods in your class?</li>
  <li><strong>What about generics?</strong> You might have thought about using protocols together with extensions (categories). But then there is an issue with generics because protocols can't have generic types, only <em>typealiases</em>.</li>
  </ol>
  
  <p>I have done my homework and I know about solving these issues using methods, such as <code>fatalError()</code> or <code>preconditionFailure()</code> in the superclass and then overriding them in a base class. But that seems like <em>ugly</em> object design to me.</p>
  
  <p>The reason I'm posting this is to find out whether there exists more general and universal solution.</p>
  
  <p>Thanks in advance,
  Petr.</p>