pascalbros pascalbros - 1 month ago 24
Swift Question

Autolayout issue Xcode 8 [_SwiftValue nsli_superitem]

Converting my code to Swift 3 I found a weird issue.
Right now (15th September 2016) Xcode 8 (public version) is out, and after converting the code, my App crashes without an apparently reason.

There is something wrong with Auto Layout and the log says something like:

[_SwiftValue nsli_superitem]: unrecognized selector sent to instance


How can I solve? Thanks

Answer

Just figured out the weird but working solution:

Instead of doing this:

let views = ["view":aView]
view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "...", options:[], metrics: metrics, views: views))

Declare the dictionary explicitly:

let views: [String:UIView] = ["view":aView]
view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "...", options:[], metrics: metrics, views: views))

I know, it's weird but it works. Cheers

Comments