Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 断言viewController是其tableView的委托和数据源_Swift_Uitableview_Uiviewcontroller_Swift3_Assert - Fatal编程技术网

Swift 断言viewController是其tableView的委托和数据源

Swift 断言viewController是其tableView的委托和数据源,swift,uitableview,uiviewcontroller,swift3,assert,Swift,Uitableview,Uiviewcontroller,Swift3,Assert,作为合理性检查,我想在viewDidLoad中声明UITableViewController(即self)被设置为其tableView的dataSource和delegate。我如何在Swift 3中实现这一点,因为(与Objective-C不同)需要额外的类型转换?这仍然会导致语法错误: assert(tableView.dataSource == self) assert(tableView.delegate == self) 可以使用对象实例相等运算符“==”执行此操作: asser

作为合理性检查,我想在
viewDidLoad
中声明
UITableViewController
(即
self
)被设置为其
tableView
dataSource
delegate
。我如何在Swift 3中实现这一点,因为(与Objective-C不同)需要额外的类型转换?这仍然会导致语法错误:

assert(tableView.dataSource == self)
assert(tableView.delegate   == self)

可以使用对象实例相等运算符“==”执行此操作:

assert(tableView.dataSource === self)
assert(tableView.delegate === self)

谢谢。新手失误!