title: Using NSPredicate to search through array of objects
body: <p>I have an array of instances of a class called <code>Contact</code>, which has, among others, the following properties:</p>
  
  <pre><code>NSArray *mailAddressList // Array of NSString
  NSArray *websiteList // Array of NSString
  NSArray *tags // Array of instances of Tag class
  </code></pre>
  
  <p>The class tag has the following properties:</p>
  
  <pre><code>NSString *name;
  UIColor *color;
  </code></pre>
  
  <p>I want to use NSPredicate to search a string in any property of each <code>Contact</code>. This is the code I have:</p>
  
  <pre><code>if([scope isEqualToString:SCOPE_MAIL] || [scope isEqualToString:SCOPE_WEBSITE])
  {
      // Search through an array
      predicate = [NSPredicate predicateWithFormat:@"ANY SELF.%@ contains[c] %@", scope, textSearch];
  }
  else if([scope isEqualToString:SCOPE_TAG])
  {
      // Search another object's property
      predicate = [NSPredicate predicateWithFormat:@"SELF.%@.name contains[c] %@", scope, textSearch];
  }
  else
  {
      // The rest of the properties are instances of NSString
      predicate = [NSPredicate predicateWithFormat:@"SELF.%@ contains[c] %@", scope, textSearch];
  }
  </code></pre>
  
  <p>Everything works fine except for <code>SCOPE_TAG</code>, it doesn't return any values. I don't think I'm using the predicate correctly.</p>
  
  <p><strong>NOTE:</strong> I'm new with NSPredicate so I would like to hear some insights if what I'm doing is not ok</p>