How to add NSConstraints to UITextView in Swift 3
<p>So I have successfully converted almost all my project to Swift 3 besides from one View Controller where I manually add constraints. </p>

<p>I was getting errors for       </p>

<pre><code>    view.addSubview(textView)

    textView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(textView)

    let views = ["textView": textView]
    var constraints = NSLayoutConstraint.constraints(withVisualFormat: "V:|-70-[textView]-8-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views)
    constraints += NSLayoutConstraint.constraints(withVisualFormat: "H:|-8-[textView]-8-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views)
    NSLayoutConstraint.activate(constraints)
</code></pre>

<p>So I changed it to </p>

<pre><code>textView.translatesAutoresizingMaskIntoConstraints = true
view.addSubview(textView)

textView.center = CGPoint(x: view.bounds.midX, y: view.bounds.midY)
textView.autoresizingMask = [UIViewAutoresizing.flexibleLeftMargin, UIViewAutoresizing.flexibleRightMargin, UIViewAutoresizing.flexibleTopMargin, UIViewAutoresizing.flexibleBottomMargin]
</code></pre>

<p>All I am trying to do is add a <code>UITextView</code> to a <code>UIView</code> in a view controller so it takes up the entire height and width and stays vertically and horizontally in the centre. I'm clearly missing something obvious with my updated code and am unsure why my previous code was refusing to run as I worked in Swift 2.2. </p>

<p>Can anyone answer the correct way of adding constraints in Swift 3 ? </p>

<p>UPDATE: </p>

<p>Here's the error from my original code which was converted to Swift 3.0 </p>

<blockquote>
  <p>2016-09-06 22:08:38.751636 APPNAME[570:65129] -[_SwiftValue
  nsli_superitem]: unrecognized selector sent to instance 0x17044a0e0
  2016-09-06 22:08:38.752963 APPNAME[570:65129] <strong>* Terminating app due
  to uncaught exception 'NSInvalidArgumentException', reason:
  '-[_SwiftValue nsli_superitem]: unrecognized selector sent to instance
  0x17044a0e0'
  *</strong> First throw call stack: (0x18430c1c0 0x182d4455c 0x184313278 0x184310278 0x18420a59c 0x184d42104 0x184d40948 0x184d3f79c
  0x184d3f340 0x100221ec0 0x1002289ac 0x100228be8 0x18a0e5b08
  0x18a19f4cc 0x18a19f3a4 0x18a19e6ec 0x18a19e138 0x18a19dcec
  0x18a19dc50 0x18a0e2c78 0x1875ab40c 0x1875a00e8 0x18759ffa8
  0x18751cc64 0x1875440d0 0x18a0d8348 0x1842b97dc 0x1842b740c
  0x1842b789c 0x1841e6048 0x185c67198 0x18a150bd0 0x18a14b908
  0x100171a04 0x1831c85b8) libc++abi.dylib: terminating with uncaught
  exception of type NSException (lldb)</p>
</blockquote>