title: Swift : Verify Core Data Attribute
body: <p>I have a Swift application with Core Data that stores the following:</p>
  
  <ul>
  <li>Username</li>
  <li>Email</li>
  <li>Key</li>
  </ul>
  
  <p>I have a ViewController to collect this information correctly setup and it is storing this information within core data. There is a textfield for all 3 attributes with a save button and it saves.</p>
  
  <p>I have another Storyboard ViewController which has a Textfield for the "key" and a Button to Verify the key along with a label to display wether the key is accepted or not.
  When the user enters the correct key a "Continue Button" Appears</p>
  
  <p>My Problem:
  At this moment my application retrieves the information and displays the saved info in my console. However, it doesn't check for the key specifically and allows any information to the Continue Button.
  How do I call the Attribute instead of the whole entity and use that info to allow continuing?
  I assume I would have to access the Entity to retrieve the attribute, but how do I do this?</p>
  
  <p>Here is my code for the Verify Button:</p>
  
  <pre><code> @IBAction func verifyKey()
  {
  
      var appDel: AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate)
      var context: NSManagedObjectContext = appDel.managedObjectContext!
  
      var request = NSFetchRequest(entityName: "User")
      request.returnsObjectsAsFaults = false
  
      var results:NSArray = context.executeFetchRequest(request, error: nil)!
  
      if (results.count &gt; 0)
      {
          btnContinueAppears.hidden = false
          keyLabel.text = "Key Accepted"
          keyLabel.resignFirstResponder()
          keyLabel.textColor = UIColor.greenColor()
          for res in results
          {
              println(res)
          }
      }
      else
      {
          btnContinueAppears.hidden = true
          keyLabel.text = ("Key Denied, Access Denied")
          keyLabel.resignFirstResponder()
          keyLabel.textColor = UIColor.redColor()
          println("0 Results Returned...Potential Error")
      }
  }
  </code></pre>