title: How to fetch core data relationships in one single NSFetchRequest?
body: <p>I have a core data app with the model setup just like the image below:</p>
  
  <p><a href="https://i.stack.imgur.com/pPHw8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pPHw8.png" alt="Core Data Model"></a></p>
  
  <p>The relationships are setup like this:</p>
  
  <p>Category&lt;-->>Subcategory&lt;-->>Item</p>
  
  <p>Now, is it possible in one single fetch to get objects from Subcategory and Item entities that have the same attribute called categoryName? I think it can be done by using relationships, but the code I am using is not working which is:</p>
  
  <pre><code>let fetchNote = NSFetchRequest(entityName: "Category")
      fetchNote.predicate = NSPredicate(format: "ANY subcategory.name == %@ AND item.name == %@", "Badaue", "Badaue")
      let notes = try! appDel.managedObjectContext.executeFetchRequest(fetchNote) as? [Category]
      print(notes)
  </code></pre>