可能是这样的
protocol GraphDataSource {
func Graph(_ graph:GraphView , row:Int)->UIView
}
protocol GraphDelegate {
func Graph(_ graph:GraphView ,didSelect row:Int)
}
class GraphView:UIView {
weak open var dataSource:GraphDataSource?
weak open var delegate:GraphDelegate?
func configureHere() {
let v = dataSource?.Graph(self, row: 0)
delegate?.Graph(self, didSelect: 0)
}
}
class ViewController: UIViewController , GraphDataSource , GraphDelegate {
let g = GraphView()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
g.delegate = self
g.dataSource = self
}
func Graph(_ graph: GraphView, didSelect row: Int) {
}
func Graph(_ graph: GraphView, row: Int) -> UIView {
}
}