如何:在显示ViewController之前检查每个值是否为零

问题描述 投票:0回答:2

下面有一个tableView委托方法

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: true)

    lessonView?.lessonName = (capturedLessons?[indexPath.row].name)!

    lessonView?.instructorGradedTracked = capturedLessons![indexPath.row].instructorGraded!

    lessonView?.expectedCompletionTimeTracked = capturedLessons![indexPath.row].expectedCompletionTime!

    self.present(self.lessonView!, animated: true, completion: nil)

}

lessonName: String
instructorGraded: Bool
expectedCompletionTime: Int

我在设置bool和int值是否为零时遇到麻烦。实施此错误处理的最佳实践方法是什么?

ios swift tableview
2个回答
1
投票

尝试这些安全的包装:


0
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.