Result of initializer is unused, I get this error in this code:
Changing it like this silences it:
_ = NSURLConnection(request: request, delegate: nil, startImmediately: true)
However it makes the code more uglier, is there a way to silence this warning without using the "_ =" ?
Edit, heres another example:
class SomeView: UIView {
init(sender: UIViewController) {
super.init(frame: CGRect(x: 10, y: 10, width: 10, height: 10))
sender.view.addSubview(self)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
SomeView(sender: self) ///Result of initializer is unused
}
}
In this example since I am adding the subview from within the view, I do not need to use the created SomeView object in anyway.
Workaround:
NSURLConnection(request: request, delegate: nil)?.start()
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