Reputation: 7559
I want to set constraint programmatically, but my Swift 1.2 code doesn't works! What had changed in Swift 2?
let topConstraint = NSLayoutConstraint(item: nvc, attribute: .Bottom, relatedBy: .Equal, toItem: nvc.superview, attribute: .Bottom, multiplier: 1, constant: 0)
nvc.superview!.addConstraint(topConstraint)
but it returns me
Type of expression is ambiguous without more context
How to fix it?
Upvotes: 0
Views: 172
Reputation: 16837
The only thing I can see being ambiguous is nvc, since you do not show us how it is defined. I typed your code using self.view in place of nvc and self.view.superview in place of nvc.superview, and the code compiled fine.
Upvotes: 2