title: Using NSPredicate to filter based on multiple keys (NOT values for key)
body: <p>I have the following NSArray containing NSDictionary(s):</p>
  
  <pre><code>NSArray *data = [[NSArray alloc] initWithObjects:
                   [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:1], @"bill", [NSNumber numberWithInt:2], @"joe", nil],
                   [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:3], @"bill", [NSNumber numberWithInt:4], @"joe", [NSNumber numberWithInt:5], @"jenny", nil],
                   [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:6], @"joe", [NSNumber numberWithInt:1], @"jenny", nil],
                   nil];
  </code></pre>
  
  <p>I am wanting to create a filtered NSArray that only contains objects where the NSDictionary matches multiple 'keys' using NSPredicate.  </p>
  
  <p>For example:</p>
  
  <ul>
  <li>filter the array to only contain the NSDictionary objects that have keys "bill" and "joe" [desired result: new NSArray would contain the <em>first</em> two NSDictionary objects]</li>
  <li>filter the array to only contain the NSDictionary objects that have keys "joe" and "jenny" [desired result: new NSArray would contain the <em>last</em> two NSDictionary objects]</li>
  </ul>
  
  <p>Can anyone please explain the format of the NSPredicate to achieve this?</p>
  
  <p>Edit:
  I can achieve a similar outcome to desired NSPredicate using:</p>
  
  <pre><code>NSMutableArray *filteredSet = [[NSMutableArray alloc] initWithCapacity:[data count]];
  NSString *keySearch1 = [NSString stringWithString:@"bill"];
  NSString *keySearch2 = [NSString stringWithString:@"joe"];
  
  for (NSDictionary *currentDict in data){
      // objectForKey will return nil if a key doesn't exists.
      if ([currentDict objectForKey:keySearch1] &amp;&amp; [currentDict objectForKey:keySearch2]){
          [filteredSet addObject:currentDict];
      }
  }
  
  NSLog(@"filteredSet: %@", filteredSet);
  </code></pre>
  
  <p>I'm imagining NSPredicate would be more elegant if one exists?</p>