请考虑以下从UITableViewController派生自定义视图控制器的代码段.
class Controller: UITableViewController { ... ) // MARK: - Table View Data Source extension Controller { override func tableView(tableView: UITableView,numberOfRowsInSection section: Int) -> Int { // call super? ... } } // MARK: - Table View Delegate extension Controller { override func tableView(tableView: UITableView,willBeginEditingRowAtIndexPath indexPath: NSIndexPath) { // call super? ... } }
You may override loadView or any other superclass method,but if you do be sure to invoke the superclass implementation of the method,usually as the first method call.
我的问题是,这是否也适用于UITableViewController符合的协议UITableViewDataSource和UITableViewDelegate中的方法?
在数据源方法中调用super对我来说没有多大意义,因为通常使用这些方法定义自己的内容.但是,我不确定委托方法.例如,在willBeginEditingRowAtIndexPath中调用super似乎没有任何明显的效果.