title: What is equivalent for C# or Java generic interface in Swift?
body: <p>I am Swift newcomer from C#. I started designing the Swift program from the abstract level - declaring entities signatures with relationships between them. I caught that protocol in swift is analog of the interface in C# or Java. From my (as Swift newcomer from C#) point of view, generics in protocols implemented in Swift by an uncommon way. I researched about associated types but continuously didn't know how to do the following:</p>
  
  <pre class="lang-swift prettyprint-override"><code>typealias Observer&lt;T&gt; = (T) -&gt; ()
  
  protocol Subscription {
      func cancel()
  }
  
  protocol Observable&lt;T&gt; {
      func subscribe(observer: Observer&lt;T&gt;) -&gt; Subscription
  }
  
  protocol A {}
  protocol B {}
  protocol C {}
  
  protocol AbcObservable {
    var aAdded : Observable&lt;A&gt; { get }
    var bAdded : Observable&lt;B&gt; { get }
    var cAdded : Observable&lt;C&gt; { get }
  }
  </code></pre>
  
  <p>The code above is from the imaginary world where generic protocols have the same struct as generic classes.  Is it possible to write the code above compilable by associated types using? How? If it is impossible, what is an alternative? </p>
  
  <hr>
  
  <p><strong>Remark 1</strong></p>
  
  <p>I need described architecture to provide something like the following:</p>
  
  <pre class="lang-swift prettyprint-override"><code>class First: AbcObservable { ... }
  class Second: AbcObservable { ... }
  
  class Client {
    let lightDependency: AbcObservable
    init(lightDependency: AbcObservable) {
      self.lightDependency = lightDependency
    }
  }
  
  class IoCContainer1 {
    let client: Client
    init() {
      let abc: AbcObservable = First()
      client = Client(abc)
    }
  }
  
  class IoCContainer2 {
    let client: Client
    init() {
      let abc: AbcObservable = Second()
      client = Client(abc)
    }
  }
  
  class Mock: AbcObservable { ... }
  
  class Test {
    func test() {
      let abcMock = Mock()
      let client = Client(abcMock)
      ...
    }
  }
  </code></pre>
  
  <p>This moment is very painfully for me; I can't understand how I can provide D of SOLID in my code in the case when I need generics.</p>
  
  <hr>
  
  <p><strong>Remark 2</strong></p>
  
  <p>Observable will not have many implementations in the real situation and it is stupid to do it as abstract. I wanted to write the essence of my problem, and I used Observable in the example to simplify. In a real situation, I had DataManager instead of Observable, that has many implementations.</p>
  
  <hr>
  
  <p><strong>Remark 3</strong></p>
  
  <p>The question was changed from "How to use protocol with associatedtype in another protocol?" to "What is equivalent for C# or Java generic interface in Swift?"</p>