Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift 3 error [_SwiftValue nsli_superitem]

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)
like image 439
RiceAndBytes Avatar asked Sep 21 '16 17:09

RiceAndBytes


1 Answers

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]
like image 73
RiceAndBytes Avatar answered Nov 06 '22 19:11

RiceAndBytes