After swift 3 conversion I have been getting this error.
'NSInvalidArgumentException', reason: '-[_SwiftValue nsli_superitem]: unrecognized selector sent to instance 0x600000a54820'
The code in question is this, it use to work fine with swift 2:
let views = ["newView": userLabel]
let widthConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:[newView(0)]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views)
userMainLabel.addConstraints(widthConstraints)
This is a issue with swift 3, where the dictionary is treated as a [String: UIView?]
The fix is to assign the type as not optional
let views: [String: UIView] = ["newView": userLabel]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With