title: Swift 4 Codable Realm Object Subclasses
body: <p>trying to switch some of my codebase over to Swift 4's new nifty <code>Codable</code> protocol. My setup looks something like this:</p>
  
  <pre><code>class Base: Object, Codable {
  
      dynamic var id: String = ""
      dynamic var timestamp: String = ""
  
      private enum CodingKeys: String, CodingKey {
  
          case id = "_id"
          case timestamp = "timestamp"
  
      }
  
  }
  
  class User: Base {
  
      dynamic var name: String = ""
  
      private enum CodingKeys: String, CodingKey {
          case name = "name"
      }
  
      required init(from decoder: Decoder) throws {
  
          let container = try decoder.container(keyedBy: CodingKeys.self)
          self.name = try container.decode(String.self, forKey: .name)
          try super.init(from: decoder)
  
      }
  
  }
  </code></pre>
  
  <p>I have a base realm object class that conforms to <code>Codable</code>, and a subclass of <code>Base</code> that also has it's own coding keys. I override <code>init(decoder:)</code> on the <code>User</code> subclass to map my additional coding keys, then call <code>super.init(decoder:)</code> to map <code>Base</code>'s coding keys. However, once I override <code>init(decoder:)</code> I get the following errors:</p>
  
  <ul>
  <li><strong>required initializer 'init()' must be provided by subclass of 'Base'</strong></li>
  <li><strong>required initializer 'init(realm:schema:)' must be provided by subclass of 'Base'</strong></li>
  <li><strong>required initializer 'init(value:schema:)' must be provided by subclass of 'Base'</strong></li>
  </ul>
  
  <p>I'm not sure what the correct way is to go about fixing these issues.</p>