I need to call a function named xyz, which is located in my ViewController class, and call it in my Cell class. This is the code that I use: ViewController
import UIKit
protocol abc {
func xyz()
}
class ViewController: UIViewController, abc {
func xyz() {
print("Hi")
}
override func viewDidLoad() {
super.viewDidLoad()
let obj = Cell.init()
obj.delegate = self
}
}
Then for my Cell class I use
var delegate: abc?
func update() {
self.delegate?.xyz()
}
Thanks