In my swift project, I have my custom delegate class. Like in objective-c, I can use my delegate
[self.delegate respondsToSelector:@selector(cancelButtonClicked:)]
But I cannot use it in swift.
here is my code
import UIKit
protocol Popup1ViewcontrollerDelegate {
func cancelButtonClicked(sender:Popup1ViewController)
}
class Popup1ViewController: WCViewController {
var delegate : Popup1ViewcontrollerDelegate?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func close(sender: AnyObject) {
if (self.delegate && self.delegaterespondsToSelector("cancelActionClicked:")) {
self.delegate?.cancelButtonClicked(self)
}
}
}