Protocol delegate method is not called..
First View controller code
class ViewController: UIViewController,customDelegate {
var seconviewcontroller : SecondViewController = SecondViewController()
@IBOutlet weak var Label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
seconviewcontroller.delegate = self
}
func didSelectData(_ result: String) {
Label.text = result
print("Didselect Data Call")
}
Second view controller code
import UIKit
protocol customDelegate: class {
func didSelectData(_ result: String)
}
class SecondViewController: UIViewController {
var delegate: customDelegate?
@IBOutlet weak var secondbutton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func secondbuttonclick(_ sender: Any) {
let selectedItem = "naga"
delegate?.didSelectData(selectedItem)
}
how to call the func didSelectData pls help me
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…