title: How to make constraint objects without VisualFormat in Swift?
body: <p>I am manually adding a bunch of layout constraints that are for portrait mode. Now I want to make two sets of constraints, and flip between them based on whether the device is in landscape or portrait mode. I do not want to use "visualformatting".</p>
  
  <p>My existing/working constraint looks like this:</p>
  
  <pre><code>mainview.addConstraint( NSLayoutConstraint(item: vPic, attribute: .Top,    relatedBy: .Equal, toItem: mainview, attribute: .Top,   multiplier: 1, constant: 0) )
  </code></pre>
  
  <p>But I want to put the constraint in to an array (along with others), and apply them when the device rotates:</p>
  
  <pre><code>var constraintsPortrait = [NSLayoutConstraint]()
  
  constraintsPortrait.extend(NSLayoutConstraint(item: vPic, attribute: .Top,    relatedBy: .Equal, toItem: mainview, attribute: .Top,   multiplier: 1, constant: 0))
  
  mainview.addConstraints(constraintsPortrait)
  </code></pre>
  
  <p>I get an error on the 2nd line:</p>
  
  <pre><code>Type 'NSLayoutConstraint' does not conform to protocol 'SequenceType'
  </code></pre>
  
  <p>The only examples I can find on the web, are for how to create the constraint as an object, using the "visualformat" syntax. Like this:</p>
  
  <pre><code>let view2_constraint_V:NSArray = NSLayoutConstraint.constraintsWithVisualFormat("V:[view2(&gt;=40)]", options: NSLayoutFormatOptions(0), metrics: nil, views: viewsDictionary)
  </code></pre>
  
  <p>Any suggestions?</p>