Xcode 8/Swift 3中“Expression of type UIViewController? is unused”警告
大家好!我是Swift新手,在使用iOS 10的Xcode 8时遇到了一个奇怪的警告。我有一个简单的代码,通过storyboard显示控制器:
```swift
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let secondVC = storyboard.instantiateViewController(withIdentifier: "SecondViewController")
self.present(secondVC, animated: true, completion: nil)
```
一切正常,但Xcode在第二行显示黄色警告:“Expression of type 'UIViewController?' is unused”。我知道这是关于未使用值的警告,但我明明在下一行使用了secondVC!我哪里做错了?以前在Swift 2中没有这种情况。如何正确编写这段代码而不出现警告?我尝试在instantiateViewController后加感叹号,但没有任何变化。也许问题在于该方法返回可选类型?请帮忙解决,谢谢。
<<>>
警告原因
在Swift