title: Dynamic type cast from id to class in objective c
body: <p>I would like to cast dynamically in Objective C and access instance properties. Here a pseudo code:</p>
  
  <pre><code>id obj;
  if (condition1)
      obj = (Class1*)[_fetchedResults objectAtIndex:indexPath.row];
  else
      obj = (Class2*)[_fetchedResults objectAtIndex:indexPath.row];
  
  NSNumber *latitude = obj.latitude;
  </code></pre>
  
  <p>Then the compiler tells me the following:
  <i>property 'latitude' not found on object of type '__strong id'</i></p>
  
  <p>Either Class1 and Class2 are core data entities and have nearly the same kind of attributes. In condition1 <i>_fetchedResults</i> returns objects of type Class1 and in condition2 <i>_fetchedResults</i> returns objects of type Class2.</p>
  
  <p>Could someone give me a hint how to solve this kind of problem?</p>
  
  <p>Thanks!</p>