title: NSPredicate to filter Custom objects based on its property from Nested structure
body: <p>I am trying to use NSPredicate to filter all CustomObjects from structure shown below, and having value true for their property "isSelected".
  I have an Nested structure like : <code>isSelectedProperty-Object-NSArray-NSDictionary-NSArray</code>.</p>
  
  <pre><code>[
    {
      "title": "ABC",
      "list": [
        &lt;CustomObject&gt;.isSelected = true,
        &lt;CustomObject&gt;.isSelected = true,
        &lt;CustomObject&gt;.isSelected = true
      ]
    },
    {
      "title": "ABC",
      "list": [
        &lt;CustomObject&gt;.isSelected = false,
        &lt;CustomObject&gt;.isSelected = true,
        &lt;CustomObject&gt;.isSelected = true
      ]
    },
    {
      "title": "ABC",
      "list": [
        &lt;CustomObject&gt;.isSelected = false,
        &lt;CustomObject&gt;.isSelected = true,
        &lt;CustomObject&gt;.isSelected = true
      ]
    }
  ]
  </code></pre>
  
  <p>From such Nested structure I need to filter all <code>CustomObject</code> having <code>isSelected = true</code> . So My Questions are,</p>
  
  <ul>
  <li>Is it possible using NSPredicate?</li>
  <li>Is Yes, then what will the predicate statement to filter this structure ?</li>
  </ul>
  
  <p>Please provide some understanding so that we can understand how to actually deal with such structures.</p>
  
  <p><em>EDIT - Very Near to Solution</em></p>
  
  <p>After googling and help of answer of Muhammad Waqas, I succeed in filtering Array as below using </p>
  
  <pre><code>NSPredicate *aPredicate = [NSPredicate predicateWithFormat:@"list.isSelected CONTAINS[c] %@",@true];
  NSArray *aArray = [mutArrContacts filteredArrayUsingPredicate:aPredicate];
  NSArray *UnWrapped = [aArray valueForKey:@"list"];
  
  
  
  &lt;__NSArrayI 0x7fc969cde360&gt;(
  &lt;__NSArrayM 0x7fc969f54a10&gt;(
  &lt;ContactData: 0x7fc969f7a590&gt;,
  &lt;ContactData: 0x7fc969f8dee0&gt;
  )
  ,
  &lt;__NSArrayM 0x7fc969f736f0&gt;(
  &lt;ContactData: 0x7fc969f68310&gt;
  )
  ,
  &lt;__NSArrayM 0x7fc969f737a0&gt;(
  &lt;ContactData: 0x7fc969f70340&gt;
  )
  ,
  &lt;__NSArrayM 0x7fc969f87430&gt;(
  &lt;ContactData: 0x7fc969f65170&gt;
  )
  ,
  &lt;__NSArrayM 0x7fc969f874d0&gt;(
  &lt;ContactData: 0x7fc969f51690&gt;
  )
  
  )
  </code></pre>
  
  <p>But Now I am struggling to filter this Objects into Single array like</p>
  
  <pre><code>(
  &lt;ContactData: 0x7fc969f7a590&gt;,
  &lt;ContactData: 0x7fc969f8dee0&gt;,
  &lt;ContactData: 0x7fc969f68310&gt;,
  &lt;ContactData: 0x7fc969f70340&gt;,
  &lt;ContactData: 0x7fc969f65170&gt;,
  &lt;ContactData: 0x7fc969f51690&gt;
  )
  </code></pre>