title: What is the pattern for entities and Equatable?
body: <p>Suppose I have this base class:</p>
  
  <pre class="lang-swift prettyprint-override"><code>class Entity: Equatable {
  
    init() {
    }
  
    var localId: Int32?
    var id: Int32?
  }
  
  func == (lhs: Entity, rhs: Entity) -&gt; Bool {
    return object_getClassName(lhs) == object_getClassName(rhs) &amp;&amp;
      lhs.localId != nil &amp;&amp;
      rhs.localId != nil &amp;&amp;
      lhs.localId == rhs.localId
  }
  </code></pre>
  
  <p>and a number of entity implementations along the lines of this:</p>
  
  <pre class="lang-swift prettyprint-override"><code>class Message: Entity {
  
    init(senderId: Int32, body: String, sentDateTime: NSDate) {
      self.senderId = senderId
      self.body = body
      self.sentDateTime = sentDateTime
      super.init()
    }
  
    var senderId: Int32
    var body: String
    var sentDateTime: NSDate
  }
  </code></pre>
  
  <p>Am I taking the right approach with the <code>Equatable</code> implementation? The reason I compare the class names is that uniqueness of <code>localId</code> is scoped to each entity type. Should I instead implement <code>Equatable</code> for each entity class? Is there an established pattern in Swift for this kind of thing?</p>