Sajad Abedi Sajad Abedi - 1 year ago 119
iOS Question

Cannot convert value of type '[NSLayoutConstraint]' error in swift 2

I want to add constraint to the

by adding this line of code:

addConstraint(NSLayoutConstraint.constraintsWithVisualFormat("H:|[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": userProfileImageView]))

But xcode show me this error:

enter image description here

How I can fix this error?

Answer Source

Use addConstraints, instead of addConstraint. constraintsWithVisualFormat returns an array.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download