title: How to Predicate through Nested Arrays with Keys
body: <p>I have an array called <code>self.eventsArray</code> which looks like this:</p>
  
  <pre><code>[ 
    {
          "artist": [
              {
                  "artist_name": "Dillon Francis", 
                  "name": "Dillon Francis", 
              }, 
              {
                  "artist_name": "Major Lazer", 
                  "name": "Major Lazer", 
              }, 
              {
                  "artist_name": "Flosstradamus ", 
                  "name": "Flosstradamus", 
              }
          ],  
          "name": "Mad Decent Block Party NYC", 
      },
    {
          "artist": [
              {
                  "artist_name": "Ryan Raddon", 
                  "name": "Kaskade", 
              }
          ], 
          "name": "Kaskade Atmosphere Tour NYC", 
      },
  ]
  </code></pre>
  
  <p>I have been trying to filter it by using <code>NSPredicate</code> two times. When the user searches, it needs to be filtered by either name (in the artist array) or name (in the top-level array).</p>
  
  <pre><code>NSPredicate *predicateEventsByName = [NSPredicate predicateWithFormat:@"SELF.%K contains[c] %@",@"name",searchText];
  NSPredicate *predicateEventsByArtistName = [NSPredicate predicateWithFormat:@"SELF.%K.%K contains[c] %@",@"artist",@"name",searchText];
  
  NSMutableArray *unfilteredEventsArray = [[NSMutableArray alloc] initWithCapacity:0];
  unfilteredEventsArray = [NSMutableArray arrayWithArray:[self.eventsArray filteredArrayUsingPredicate:predicateEventsByName]];
  [unfilteredEventsArray addObjectsFromArray:[self.eventsArray filteredArrayUsingPredicate:predicateEventsByArtistName]];
  
  
   [self.filteredEventsArray addObjectsFromArray:[[NSSet setWithArray:unfilteredEventsArray] allObjects]];
  </code></pre>
  
  <p>Using this code, <code>self.filteredEventsArray</code> will be populated with any search term matching the top-level <code>"name"</code>. It won't give any search results for the nested artist <code>"name"</code>.
  I suspect the reason why it won't search through the nested array is because of this line:</p>
  
  <pre><code>NSPredicate *predicateEventsByArtistName = [NSPredicate predicateWithFormat:@"SELF.%K.%K contains[c] %@",@"artist",@"name",searchText];
  </code></pre>
  
  <p>but I can't figure out how to change the <code>predicateWithFormat:</code> to make it search through the nested array.</p>