title: Core Data : Get Records where more than one objects available in relationship
body: <p>I have one Entity Category which can contain subcategories of the same type so I want only those categories which have more than 1 subcategory available.</p>
  
  <p>Here is the schema of the entity.
  <a href="https://i.stack.imgur.com/nt6DW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nt6DW.png" alt="Schema"></a></p>
  
  <p>Here is my code to get the details.</p>
  
  <pre><code>func getAllCategory() -&gt; [TestCategory] {
      let fetchRequest = NSFetchRequest&lt;Category&gt;(entityName: "\(Category.self)")
      fetchRequest.includesSubentities = true
      fetchRequest.predicate = NSPredicate.init(format: "%K.count &gt; %i","childCategories",0)
      do {
          let results = try self.getCurrentContext().fetch(fetchRequest)
      } catch  {
      }
  }
  </code></pre>
  
  <p>Here is the error I am getting.</p>
  
  <pre><code>CoreData: error: SQLCore dispatchRequest: exception handling request: &lt;NSSQLFetchRequestContext: 0x600000a34a80&gt; , to-many key not allowed here with userInfo of (null)
  </code></pre>
  
  <p>Thanks</p>