title: Combining 2 values into a NSPredicate
body: <p>I'm trying to do a fetch request that checks for 2 things.</p>
  
  <p>Here is my Data:</p>
  
  <p>Person - entity
  Statement - entity
  The Person entity has a relationship to statements as To Many. The statement entity has an attribute called amountOwed. This is the property I want to check in the predicate. </p>
  
  <p><strong>EDIT</strong>
  What I am trying to do is this. 
  Check all of my Persons entities for a name, lets say Bob.</p>
  
  <p>Once I find the Bob entity I want to check all of his Statement entities for an attribute called amountOwed and see if it's greater or less then 0.</p>
  
  <ol>
  <li>Check for a name in the Person Entity. When that name matches, use that entity.</li>
  <li>Check if the amountOwed in a Statement entity is greater or less then 0.</li>
  </ol>
  
  <p>This is what I have been trying to get to work.</p>
  
  <pre><code>let fetchRequest: NSFetchRequest&lt;Person&gt; = Person.fetchRequest()
  fetchRequest.predicate = NSPredicate(format:"name == %@ AND @statement.amountOwed &gt;= 0", personName))
  let sort = NSSortDescriptor(key: #keyPath(Person.name), ascending: true)
  fetchRequest.sortDescriptors = [sort]
  positiveFetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: coreDataStack.managedContext, sectionNameKeyPath: nil, cacheName: nil)
  
  do {
      try positiveFetchedResultsController.performFetch()
  } catch let error as NSError{
      print("Fetching error: \(error), \(error.userInfo)")
  }
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here'
  </code></pre>
  
  <p>I found the AND method here: <a href="https://stackoverflow.com/questions/33321050/combining-two-conditions-in-nspredicate">using AND link</a></p>
  
  <p><strong>Edit</strong>
  <a href="https://i.stack.imgur.com/eYSfG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eYSfG.png" alt="enter image description here"></a></p>