Upgrading to beta6 of Xcode8, I’ve read through various SE’s and made fixes as
appropriate, but the following behavior I didn’t catch an explanation as to why
its now an error where it was fine before.
In a ViewController, I have something that looks like:
var addButton = UIButton(type: .custom)
var addPrompt = UILabel()
var timesButton = UIButton(type: .system)
var removeButton = UIButton(type: .system)
var menuButton = UIButton(type: .system)
func commonInit() {
[self.addButton, self.addPrompt, self.timesButton, self.removeButton,
self.menuButton].forEach { control in
control.sizeToFit()
self.addSubview(control)
}
This code was fine until the latest update. It seemed to a heterogenous array
of UILabel and UIButtons was a homogeneous array of UIView objects. But now I
get the errors:
Value of type ‘Any’ has no member ‘sizeToFit'
Cannot covert value of type ‘Any’ to expected argument type of ‘UIView’
This seems like it might be related to SE-0116 (Import Objective-C id as Swift
Any ) but I’m not sure why the inferencer can no longer find the shared parent
type, where it could before.
Aside, I can fix it by simply helping it a little, e.g.
[self.addButton, self.addPrompt, self.timesButton, self.removeButton,
self.menuButton].forEach { (control:UIView) in...
But remain curious why the inferencer can’t handle this for me anymore.
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users