title: Use NSExpression CAST with NSPredicate in Core Data
body: <p>My problem is exactly the same as you can read in this thread:
  <a href="https://stackoverflow.com/questions/13224601/is-it-possible-use-nested-subquery-in-nspredicate">stackoverflow thread</a></p>
  
  <p>But there is a small difference. I try to explain it using the above thread's image.
  The CS relationship contains <code>C</code> type objects as it is described, but also contains <code>E</code> type objects too, because the <code>E</code> type objects are derived from the <code>C</code> type object.  </p>
  
  <p>On thread's image the <code>E</code> type object is not present and this is the difference. The <code>E</code> type property also has a <code>CS</code> relationship.</p>
  
  <p>The problem comes when I try to reach the <code>E</code> type object's <code>CS</code> property using the following query: <code>SUBQUERY(bs, $x, ANY $x.cs.cs ....</code>  </p>
  
  <p>The query is not finished, but the important code is there. As I observed, the predicate creation fails, because it tries to use the <code>CS</code> relationship on the <code>C</code> type object. I've tried to use the <code>CAST</code> operator on the <code>$x.cs</code> variable without success.  </p>
  
  <p>Do anybody has a clue for this?</p>
  
  <hr>
  
  <p>Edit: Added image<br>
  <img src="https://i.stack.imgur.com/w2SMn.png" alt="enter image description here"></p>
  
  <p>The <code>values</code> of the <code>MKMultiAttribute</code> entity can contain <code>MKAttribute</code> and <code>MKMultiAttribute</code> types. And this is the problem, because the <code>values</code> is set to be a relationship to <code>MKAttribute</code>, but, because <code>MKMultiAttribute</code> is derived from <code>MKAttribute</code> the <code>values</code> can contain <code>MKMultiAttribute</code> entities and currently I can't call the <code>values</code> again.</p>