title: NSPredicate nested dictionary dynamic key
body: <p>I am using core data to fetch a list of objects. These objects have a property named 'categories'. This categories property is a NSDictionary constructed from json like :</p>
  
  <pre><code>@{@"A":@YES, @"B":@NO, @"C":@YES}
  </code></pre>
  
  <p>I want to get all core data objects which category is true for a given category key.
  I tried :</p>
  
  <pre><code>NSString *categoryKey = @"A";
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"categories.%K == YES", categoryKey]];
  // or
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.categories.%@ == YES", categoryKey]];
  // or
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"categories[%@] == YES", categoryKey];
  // Throws exception : Unsupported function expression categories["A"]
  // or
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"categories[%K] == YES", categoryKey];
  // Throws exception : Unsupported function expression categories[A]
  // or
  NSString *categoryKeyPath = [NSString stringWithFormat:@"categories.%@", categoryKey];
  NSPredicate *p = [NSPredicate predicateWithFormat:@"%K == YES", categoryKeyPath]];
  </code></pre>
  
  <p>But it always returns empty array when performing my fetch (of course I have some objects with <code>categories[@"A"] = YES</code>).
  I think the problem comes from nested dictionary key path but I can't find a way to achieve this with one predicate.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>To clarify I would use</p>
  
  <pre><code>NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
      return [[evaluatedObject.categories objectForKey:categoryKey] boolValue];
  }];
  </code></pre>
  
  <p>But <code>predicateWithBlock:</code> is not supported when fetching in core data.</p>