title: How to define variable that can be set and get in extension of protocol
body: <p>I come from Java world. Now I am programming in Swift 4.</p>
  
  <p>I would like to implement abstract class in Swift, I know in Swift there is no such concept of abstract class. But I know we could mimic this concept in Swift by using protocol. For example this is what I tried:</p>
  
  <pre><code>// With protocol, I can define functions that concrete class have to implement
  protocol ProductProvider {
     func getProductNumber() -&gt; Int
  }
  
  // with protocol extension, I can define shared (computed) properties and functions among concrete classes that comply with this protocol
  extension ProductProvider {
    var maxProductCount: Int {
          return 10
    }
  }
  </code></pre>
  
  <p>But now, I would like to have a shared variable that could be set &amp; get ("shared" means to be shared with classes that comply with this protocol):</p>
  
  <pre><code>extension ProductProvider {
    var maxProductCount: Int {
          set(newValue) {
             // set to what if I couldn't define private stored variable in extension to hold the most recent set value ?
          }
          get{
             // how to return the most recent value set?
          }
    }
  }
  </code></pre>
  
  <p>My question is in the comment of above code. How can I do that set and get for a variable in extension of protocol in Swift 4? If it is impossible, what are the workarounds possible?</p>