title: How can I get the value of the primary key of an NSManagedObject?
body: <p>I found out that Core Data is basically an SQLite database. Each entity is a separate table. There are also tables which are not entities, including <code>Z_METADATA</code>, <code>Z_MODELCACHE</code> and <code>Z_PRIMARYKEY</code>. I don't know what they do.</p>
  
  <p>Anyway, I saw that the fields of the "entity tables" is roughly the same as those properties I added in the data model, plus a few extras. For example, if my entity has only one property called <code>date</code>. The table will have a <code>ZDATE</code> field as well as <code>Z_PK</code>, <code>Z_ENT</code>, and <code>Z_OPT</code>.</p>
  
  <p>So apparently, each entity has a primary key that is stored in the <code>Z_PK</code> field! I want to get the value of this primary key of a specific <code>NSManagedObject</code>. And I want to query the database for an <code>NSManagedObject</code> that has a specific primary key.</p>
  
  <p>So basically, something like this:</p>
  
  <pre><code>let pk = myManagedObject.primaryKey
  // the below should return myManagedObject
  managedObjContext.objectWithPrimaryKey(someEntityDescription, pk)
  </code></pre>
  
  <p>I searched the docs for <code>NSManagedObject</code> and saw an <code>objectID</code>. But I don't think this is it, or is it?</p>