title: Changing constraint after adding it causes constraint error (swift)
body: <p>I'm working on adding error messages to my login screen.</p>
  
  <p>While the code runs fine, and does what I want it to do. It causes a constraint error on execution.</p>
  
  <p>Here are the effected constraints:</p>
  
  <pre><code>self.view.addConstraints(
      NSLayoutConstraint.constraintsWithVisualFormat(
          "V:|[topBar]-32-[emailInputField]-32-[passwordInputField]-32-[signInButton]-16-[resetPasswordButton]-[signUpButton]", options: nil, metrics: nil, views: viewsDictionary))
  self.view.addConstraints(
      NSLayoutConstraint.constraintsWithVisualFormat(
          "V:|[topBar]-32-[emailIconBox]-32-[passwordIconBox]", options: nil, metrics: nil, views: viewsDictionary))
  </code></pre>
  
  <p>And here is the function that causes the errorView to appear.</p>
  
  <pre><code>// sign in button function
  func signIn(sender: UIButton) {
  self.view.endEditing(true)
  
  if emailInputField.text.isEmpty {
      println("NO EMAIL")
  
      errorLabel.attributedText = UILabel.ErrorMessage("Form fields cannot be empty!")
  
  
      var viewsDictionary = [ "topBar":topBar,
          "errorView":errorView,
          "errorLabel":errorLabel,
          "emailInputField":emailInputField,
          "emailIconBox":emailIconBox,
          "passwordInputField":passwordInputField,
          "passwordIconBox":passwordIconBox,
          "signInButton":signInButton,
          "resetPasswordButton":resetPasswordButton,
          "signUpButton":signUpButton]
  
      self.view.addConstraints(
          NSLayoutConstraint.constraintsWithVisualFormat(
              "V:|[topBar]-16-[errorView]-16-[emailInputField]-32-[passwordInputField]-32-[signInButton]-16-[resetPasswordButton]-[signUpButton]", options: nil, metrics: nil, views: viewsDictionary))
      self.view.addConstraints(
          NSLayoutConstraint.constraintsWithVisualFormat(
              "V:|[topBar]-16-[errorView]-16-[emailIconBox]-32-[passwordIconBox]", options: nil, metrics: nil, views: viewsDictionary))
      self.view.addConstraints(
          NSLayoutConstraint.constraintsWithVisualFormat(
              "V:[errorView(50)]", options: NSLayoutFormatOptions(0), metrics: nil, views: viewsDictionary))
  }
  }
  </code></pre>
  
  <p>How do I change the constraints without breaking them?</p>
  
  <p>I tried self.view.updateConstraints() - but that did nothing.
  I also tried removing the constraints just before adding them, but there was still an error.</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>EDIT:</p>
  
  <p>I found an objective-c solution, to the constraint a variable with a constant and then changing the constant. - I tried translating this to swift. There's no errors when I run it, but my errorView does not show up (height doesn't change)</p>
  
  <p>here's what I tried:</p>
  
  <ol>
  <li><p>I declared the variable in the ViewController class (before viewDidLoad)</p>
  
  <p>var errorViewHeight = NSLayoutConstraint()</p></li>
  <li><p>in the beginning of my function, I specify it.</p>
  
  <p>errorViewHeight = NSLayoutConstraint(item:errorView, attribute:NSLayoutAttribute.Height, relatedBy:NSLayoutRelation.Equal, toItem:nil, attribute:NSLayoutAttribute.NotAnAttribute, multiplier:1.0, constant:0)</p></li>
  <li><p>and lastly, after an if statement returns true, I attempt to animate it.</p>
  
  <p>UIView.animateWithDuration(0.2, animations: { () -> Void in
              self.errorViewHeight.constant = 50
              self.view.layoutIfNeeded()
          })</p></li>
  </ol>
  
  <p>EDIT:</p>
  
  <p>Here's the error message:</p>
  
  <pre><code>Unable to simultaneously satisfy constraints.
      Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
  (
      "&lt;NSLayoutConstraint:0x170089e20 V:[UIView:0x174191780(0)]&gt;",
      "&lt;NSLayoutConstraint:0x170089fb0 V:[UIView:0x174191780(50)]&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x170089fb0 V:[UIView:0x174191780(50)]&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful.
  </code></pre>