ios - Swift 3.0 Delegate Protocol doesn't work -




i have made delegate protocol within 2 view controllers. delegate method doesn't call on code snippet. reason that. couldn't find out issue kindly post suggestions relive issue.

main view controller

class viewcontroller: uiviewcontroller, testdelegatemethod {  override func viewdidload() {     super.viewdidload()      let vw = testviewcontroller()     vw.delegatetest = self      let push = self.storyboard?.instantiateviewcontroller(withidentifier: "testviewcontroller")     self.navigationcontroller?.pushviewcontroller(push!, animated: true) }  func testmethod(value:string) {     print("hai", value) } } 

sub view controller

protocol testdelegatemethod { func testmethod(value:string) }  class testviewcontroller: uiviewcontroller { var delegatetest : testdelegatemethod?  override func viewdidload() {     super.viewdidload() }  @ibaction func actsubmit(_ sender: any) {     delegatetest?.testmethod(value: "hello how you!") }  } 

update these changes in viewdidload() method

override func viewdidload() {     super.viewdidload()     if let push = self.storyboard?.instantiateviewcontroller(withidentifier: "testviewcontroller") as? selectionscreen   {     push.delegatetest = self   }  } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -