title: How to determine if NSLayoutConstraint is horizontal or vertical?
body: <p>This seems like it should be a simple task, but is there a way of telling programmatically if a <code>NSLayoutConstraint</code> is a horizontal or vertical constraint?</p>
  
  <p>The only way I can think of to attempt making this difference is by calling <code>[constraint description];</code> and then searching the resulting string for <code>"V:"</code> or <code>"H:"</code></p>
  
  <p>The reason I want to find this information is I have 2 nearly identical constraints set on a <code>prototype</code> <code>UITableViewCell</code> on my <code>storyboard</code>, the only difference being one describes the horizontal distance from the <code>superview</code>, and the other the vertical. I want to remove the vertical, programmatically add constraints to describe a new view being added given a certain parameter being returned from my server.</p>
  
  <p>Any suggestions would be extremely helpful!</p>
  
  <h1>EDIT:</h1>
  
  <p>I accepted greymouser's answer because his explanation is a fantastic answer and is the way I ended up working around parsing the description, but also want to give credit to @kongtomorrow who also suggested this answer via twitter just before greymouser answered me here! Thanks for the help!</p>
  
  <p>Here is the actual code I used to find the constraint:</p>
  
  <pre><code>NSArray *constraints = [bubble constraints];
  
  for (NSLayoutConstraint *constraint in constraints) {
      if ([[constraint firstItem] isEqual:messageLabel] &amp;&amp; [[constraint secondItem] isEqual:bubble] &amp;&amp; [constraint secondAttribute] == NSLayoutAttributeTop) {
          [bubble removeConstraint:constraint];
      }
  }
  </code></pre>
  
  <p>The above matches the firstItem, secondItem, and then secondAttribute of the constraint to confirm with reasonable certainty that I am looking at the right constraint, then I remove it and successfully add my new constraint-descriptions after!</p>