title: Does iOS change reference of objects?
body: <p>I don't have too much experience with iOS, but I am working on some legacy code. In the project, we use an object as the key of a dictionary:</p>
  
  <pre><code>NSMutableDictionary * dict;
  RoleContainer * role = [Class getRole];
  [dict setObject:[Class getData] forKey:role];
  </code></pre>
  
  <p>We have the role passed to another function. When we try to retrieve the data:</p>
  
  <pre><code>data = [dict objectForKey:role];
  </code></pre>
  
  <p>Sometimes the return value is empty. It happens about 10% of time. I stepped through the code and found out after passing role to the function the reference of the "role" object had been changed! For example, from 0x002bf500 to 0x00222bad. </p>
  
  <p>Why?</p>