I am trying to use protocols with swift. I don't know why it is not working.
Second View controller:
protocol passBackTheVoice {
func sendVoiceMessage(name: String)
}
class VoiceRecordViewController: UIViewController {
var passBackDelegate: passBackTheVoice?
….
….
func uploadCompleted() {
self.passBackDelegate?.sendVoiceMessage(voiceName)
self.dismissViewControllerAnimated(true, completion: nil)
}
}
First View Controller:
class ChatViewController: UIViewController, passBackTheVoice {
var voiceRecordVC = VoiceRecordViewController()
override func viewDidLoad() {
voiceRecordVC.passBackDelegate=self
}
func sendVoiceMessage(name: String) {
print("chat view \(name)")
}
}
My sendVoiceMessage method is not calling. Where is the problem and how can i solve?
Ps: Don't know this is related but, firstly my ChatViewController is showing then user touches to a button i am showing VoiceRecordViewController to user. Then user creating a voice file and i want to pass back this file to my ChatViewController.