Delegate seems to not be working, according to the console

南笙酒味 提交于 2019-12-02 04:20:10

Whenever you used delegates you need to pass that delegate from one view controller to another view controller. According to Apple definition:

Delegation is a simple and powerful pattern in which one object in a program acts on behalf of, or in coordination with, another object. The delegating object keeps a reference to the other object–the delegate–and at the appropriate time sends a message to it. The message informs the delegate of an event that the delegating object is about to handle or has just handled. The delegate may respond to the message by updating the appearance or state of itself or other objects in the application, and in some cases it can return a value that affects how an impending event is handled. The main value of delegation is that it allows you to easily customize the behavior of several objects in one central object.

The missing part you are doing is that you are not calling the delegate for expample you called JournalTextDelegate in your class JournalEntryController so you need to call this JournalTextDelegate to your JournalPage.

for example: Suppose your going to another view controller through push method

let vc = self.storyboard?.instantiateViewController(withIdentifier: “identifierier”) as! JournalPage
 vc.delegate = self // you need to call this delegate
 self.navigationController?.pushViewController(notifDetailVCObj, animated: true)

And it will work fine. For reference see documentation https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/DelegatesandDataSources/DelegatesandDataSources.html

You delegate from pageview controller:

{your JournalPage controller object}.delegate = self
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!