Reputation: 8579
since migrating to Swift 3 for the following code:
func setup() {
Bundle.main.loadNibNamed("SomeNib", owner: self, options: nil)?[0] as! UIView
self.addSubview(customView)
customView.frame = self.bounds
}
I am now getting the warning: Expression of type 'UIView' is unused
. What am I doing wrong here?
Upvotes: 1
Views: 5006
Reputation: 57169
You never declared and set the customView which is why the compiler is complaining about not using the result of loadNibNamed
.
let customView = Bundle.main.loadNibNamed("SomeNib", owner: self, options: nil)?[0] as! UIView
Upvotes: 7