ios - [UIViewController] 类型的表达式?没用过

标签 ios swift xcode uiviewcontroller

<分区>

我刚刚迁移到 Xcode 8.0,并从 Swift 2.2 迁移到 Swift 3.0。

我用这个方法得到了一个 UITableViewController:

@IBAction func cancelToLastLevelNavigationController(_ segue:UIStoryboardSegue) {

    // go back to last table view controller
    let count = self.navigationController?.viewControllers.count
    self.navigationController?.popToViewController((self.navigationController?.viewControllers[count! - 1])!, animated: true)
}

现在 XCode 告诉我“[UIViewController] 类型的表达式?未使用”并指向“popToViewController”的第一个“p”。

为什么?该方法仍然执行它应该执行的操作。

最佳答案

这样写:

_ = self.navigationController?.popToViewController...

您的代码完全一样,警告消失了。

关于ios - [UIViewController] 类型的表达式?没用过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39690102/

相关文章:

ios - 如何将数据传输到 Swift 中的幻灯片菜单

ios - 重写 ios 方法时何时使用 super

ios - E2E : Select an image from a UIImagePickerController with Wix Detox

ios - Swift 数组元素映射

ios - 在 xcode 中存档时,Ionic Framework Hackishly 隐藏输入错误

ios - 使用 Codable 转换为对象

iphone - uitableViewcell 中的 UIImage 会减慢滚动表的速度

ios - 位置管理器 :didEnterRegion method is not getting called when screen is off

ios - TableView 的 UISearchController

ios - 使用 Alamofire 和 Swift 3 反序列化复杂的 JSON