<分区>
我想重用下面的代码
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 3
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return UITableViewCell()
}
我定义一个协议(protocol):
protocol ConfigDetail: class, UITableViewDataSource{}
extension ConfigDetail{
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 3
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return UITableViewCell()
}
}
但是当我将协议(protocol)与 UIViewController 一起使用时,它总是告诉我我不符合协议(protocol) UITableViewDataSource,或者我必须在我的协议(protocol)之前添加 @objc。但是我在协议(protocol)中定义了结构变量,@objc 可能无济于事。有什么解决办法吗?