title: How to resolve dynamicCastClassUnconditional breakpoint when calling existingObjectWithID
body: <p>I'm creating an iOS app with swift and Xcode 6. I have a set of views that act as a wizard. In the first one I create an NSManagedObject. Then I pass its objectID to the next view. In the next view I look up the object using existingObjectWithID. The object is found but the debugger stops at a EXC_BREAKPOINT. Here are snippets from the code and the stack of the breakpoint. How do I get rid of this?</p>
  
  <pre><code>let context: NSManagedObjectContext = appDel.managedObjectContext!
  let en = NSEntityDescription.entityForName("MyDataModel", inManagedObjectContext: context)
  var d = MyDataModel(entity: en!, insertIntoManagedObjectContext: context)
  d.name = nameField.text
  d.autoplay = true
  context.save(nil)
  self.mydataId = d.objectID
  </code></pre>
  
  <p>Then in the next view I get the object with the following code (mydataId is passed from the first view controller to the second.</p>
  
  <pre><code>var error: NSError?
  let appDel: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
  let context: NSManagedObjectContext = appDel.managedObjectContext!
  var d: MyDataModel = context.existingObjectWithID(mydataId, error: &amp;error) as MyDataModel
  if error != nil {
      println(error)
  }
  </code></pre>
  
  <p>Here is what the debug screen looks like when it breaks.</p>
  
  <pre><code>libswiftCore.dylib`swift_dynamicCastClassUnconditional:
  0x10fcdf7d0:  pushq  %rbp
  0x10fcdf7d1:  movq   %rsp, %rbp
  0x10fcdf7d4:  testq  %rdi, %rdi
  0x10fcdf7d7:  je     0x10fcdf80e               ; swift_dynamicCastClassUnconditional + 62
  0x10fcdf7d9:  movabsq $-0x7fffffffffffffff, %rax
  0x10fcdf7e3:  testq  %rax, %rdi
  0x10fcdf7e6:  jne    0x10fcdf80e               ; swift_dynamicCastClassUnconditional + 62
  0x10fcdf7e8:  movq   0xae741(%rip), %rax       ; swift::ISAMask
  0x10fcdf7ef:  andq   (%rdi), %rax
  0x10fcdf7f2:  nopw   %cs:(%rax,%rax)
  0x10fcdf800:  cmpq   %rsi, %rax
  0x10fcdf803:  je     0x10fcdf81d               ; swift_dynamicCastClassUnconditional + 77
  0x10fcdf805:  movq   0x8(%rax), %rax
  0x10fcdf809:  testq  %rax, %rax
  0x10fcdf80c:  jne    0x10fcdf800               ; swift_dynamicCastClassUnconditional + 48
  0x10fcdf80e:  leaq   0x332fd(%rip), %rax       ; "Swift dynamic cast failed"
  0x10fcdf815:  movq   %rax, 0xae5cc(%rip)       ; gCRAnnotations + 8
  0x10fcdf81c:  int3   
  0x10fcdf81d:  movq   %rdi, %rax
  0x10fcdf820:  popq   %rbp
  0x10fcdf821:  retq   
  0x10fcdf822:  nopw   %cs:(%rax,%rax)
  </code></pre>
  
  <p>It stops at the last "movq" line. I hope someone knows how to get rid of this.</p>