title: Swift sometimes calls wrong method
body: <p>I noticed strange behaviour during working with Swift projects. I can't explain it other than Swift sometimes calls wrong method. It is very rare and even adding blank lines to the code could lead that this error is gone.</p>
  
  <p>Let me explain in screenshots what I mean, next I use CoreData example of SwiftDDP project that can be found on Github, but such issues I was able to see in my own projects.</p>
  
  <p>Here we at <code>Todos.swift:74</code> where you can see breakpoint, I expect that next call should be <code>getId()</code> method of <code>MeteorClient</code> class because it was already instantiated:</p>
  
  <p><a href="https://i.stack.imgur.com/7F4mM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7F4mM.png" alt="Screenshot 1"></a></p>
  
  <p>After Step Into as you can see the <code>ping()</code> of the same instance is called:</p>
  
  <p><a href="https://i.stack.imgur.com/mMsDg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mMsDg.png" alt="Screenshot 2"></a></p>
  
  <p>The next two steps into lead to <code>EXC_BAD_ACCESS</code> exception:</p>
  
  <p><a href="https://i.stack.imgur.com/SGdYE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SGdYE.png" alt="Screenshot 3"></a></p>
  
  <p>In my project I saw this issue fairly often before I stopped using singletons, so it could be related to Swift static memory usage or I don't understand something that is not surprising as I have little experience with multithreading and memory management.</p>
  
  <p>My environment is:</p>
  
  <ul>
  <li>AppCode OC-145.184.11</li>
  <li>Xcode Version 7.2.1 (7C1002)</li>
  <li>iOS 9.2 SDK</li>
  <li>Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)</li>
  </ul>
  
  <p><strong>NOTE</strong>: Here I use AppCode but the same behavior I was able see in Xcode, and even more if the same issue that reproduces in Xcode could not reproduce in AppCode and vice versa.</p>
  
  <p>Would be thankful if someone can explain this strange behaviour to me.</p>
  
  <p>Thanks!</p>