title: Checking to make sure Entity attributes in Core Data are not the same when saved
body: <p>I have an app that is using Core Data. I have the app being able to add a new Entity and fill out the "name" attribute of that Entity. What I'm not sure how to do is make sure that there are not 2 Entities created with the same "name" attribute. I have read this article (<a href="http://blog.zachorr.com/post/129785280807/core-data-unique-constraints" rel="nofollow">Constraints in Core Data</a>) on unique constraints and it seems a tad above where I am. So I am trying to take the code at the top of the page and implement that. Here is what I have:</p>
  
  <pre><code>// check to see if the name is already saved
          // check to see if the name is already saved
          let fetchRequest = NSFetchRequest(entityName: "Person")
  
          fetchRequest.resultType = .ManagedObjectIDResultType
  
          let predicate = NSPredicate(format: "name = %@ ", name)
  
          let results = coreDataStack.context.executeFetchRequest(fetchRequest)
  
          if (results.name == personName.text) {
              //don't use it!
          } else {
              //create it!
          }
  </code></pre>
  
  <p>The part that I'm not sure about is the NSPredicate, I want to look over my fetch request for the "name" attribute found on each Person Entity.</p>