title: iOS - How to conform to NSItemProviderWriting and NSItemProviderReading protocol on class using Generics
body: <p>I am using a custom class <code>CollectionViewConfigurator</code> to handle the configuration of my CollectionViewCell in a generic way.</p>
  
  <p>It is working perfectly, here is the sample class :</p>
  
  <pre><code>protocol ConfigurableCell {
  
      static var reuseIdentifier: String { get }
  
      associatedtype DataType
  
      func configure(data: DataType)
  }
  
  extension ConfigurableCell {
      static var reuseIdentifier: String { return String(describing: Self.self) }
  }
  
  protocol CellConfigurator {
      static var reuseId: String { get }
      func configure(cell: UIView)
      var hash: Int { get }
  }
  
  class CollectionViewCellConfigurator&lt;CellType: ConfigurableCell, DataType: Hashable&gt;: CellConfigurator where CellType.DataType == DataType, CellType: UICollectionViewCell {
  
      static var reuseId: String { return CellType.reuseIdentifier }
  
      let item: DataType
  
      init(item: DataType) {
          self.item = item
      }
  
      func configure(cell: UIView) {
          (cell as! CellType).configure(data: item)
      }
  
      var hash: Int {
          return String(describing: CellType.self).hashValue ^ item.hashValue
      }
  }
  
  extension Int: Diffable {
      public var diffIdentifier: AnyHashable {
          return self
      }
  }
  </code></pre>
  
  <p><strong>NB:</strong> I was inspired by a very good article demonstrating the same use for <code>UITableView</code>. I tried it on my <code>UICollectionView</code> and it is fantastic.</p>
  
  <p>Anyway, I would like to handle the <strong>Drag and Drop</strong> within this <code>UICollectionView</code>.</p>
  
  <p>To do so, if I understand the delegate methods correctly, my items in the UICollectionView need to conform to the <code>NSItemProviderWriting</code> and <code>NSItemProviderReading</code> protocol.</p>
  
  <p>When I added the protocol methods, here was the error :</p>
  
  <blockquote>
    <p>Static stored properties not supported in generic types</p>
  </blockquote>
  
  <p>I then read this <a href="https://stackoverflow.com/questions/37963327/what-is-a-good-alternative-for-static-stored-properties-of-generic-types-in-swif">post</a> to understand the error and to try to bypass this.</p>
  
  <p>But I am afraid I am digging into a very complex area of the language.</p>
  
  <p>Can someone explain me how to conform to those protocols with my Class using Generics?</p>