title: How to use Core Data Integer 64 with Swift Int64?
body: <p>I have a CoreData attribute on an entity on which I want to store integer values larger than <code>Int32.max</code> and <code>UInt32.max</code>. The value is used as an index, so lookup performance matters. So I've opted to use <code>Integer 64</code> as datatype in CoreData.</p>
  
  <p>Now I'm struggling on how to store an Int64 on my entity instance. See also the following different approaches I've tried.</p>
  
  <p>Use <code>NSNumber</code>:</p>
  
  <pre><code>import Foundation
  import CoreData
  
  class Node : NSManagedObject {
      @NSManaged var id : NSNumber
  }
  
  node.id = Int64(1)
  &gt; 'Int64' is not convertible to 'NSNumber'
  </code></pre>
  
  <p>Use <code>NSInteger</code>:</p>
  
  <pre><code>import Foundation
  import CoreData
  
  class Node : NSManagedObject {
      @NSManaged var id : NSInteger
  }
  
  node.id = Int64(1)
  &gt; 'Int64' is not convertible to 'NSInteger'
  </code></pre>
  
  <p>Use <code>Int64</code>:</p>
  
  <pre><code>import Foundation
  import CoreData
  
  class Node : NSManagedObject {
      @NSManaged var id : Int64
  }
  
  node.id = Int64(1)
  &gt; EXC_BAD_ACCESS (code=1, address=...)
  </code></pre>
  
  <p>How should the attribute be defined / assigned in order to use 64 bit integers?</p>