title: Using NSPredicate to find an object with a key starting with an @
body: <p>I have this JSON object that I load into an NSDictionary:</p>
  
  <pre><code>media =     {
         photos =         {
             photo =             (
                                 {
                     "$t" = "http://some url";
                     "@id" = 1;
                     "@size" = x;
                 },
                                 {
                     "$t" = "http://another url";
                     "@id" = 1;
                     "@size" = fpm;
                 },
                                 {
                );
         };
  };
  </code></pre>
  
  <p>I am trying to search the photos array and return just the photo with the @size attribute = x.  </p>
  
  <p>I thought this would work but it is returning zero objects:</p>
  
  <pre><code> NSObject *photo = [[photos valueForKeyPath:@"media.photos.photo"] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"%@ == x",@"@size"]];
  </code></pre>
  
  <p>I have tried putting single quotes around the 'x' but that fails too.  I think it is the @ sign in the attribute name itself that is causing the problem.  Any help would be greatly appreciated.</p>
  
  <p>EDIT</p>
  
  <p>The key starting with the @ seems to be the problem.  If I try to use NSPredicate to search the array it throws a "NSUnknownKeyException... class is not key value compliant" error.  </p>
  
  <p>I am able to search with nested for loops like this:</p>
  
  <blockquote>
  <pre><code>for (id photo in photos)
   {
       for (id key in photo) 
       {
           id value = [photo objectForKey:key];
  
           if ([key isEqualToString:@"@size"] &amp;&amp; [value isEqualToString:@"x"])
           {
             stringXLargePhotoUrl = [photo valueForKey:@"$t"];
             break;
            }
        }
        if (stringXLargePhotoUrl != Nil)
           break;
     }
  </code></pre>
  </blockquote>
  
  <p>But that is pretty clunky.  I would rather use the NSPredicate if possible.  I don't control the JSON object so I can't just change key to not start with an @.</p>