Delegates illustration

Could u please illustrate this more

Giving AddItemViewController a direct reference to ChecklistViewController prevents you from opening the Add Item screen from somewhere else in the app. It can only ever talk back to ChecklistViewController. That’s a big disadvantage.

Can you explain to me what exactly is confusing you in that particular statement? What part do you want explained more?

Thx Fahim
How it prevents the the Add Item screen from somewhere else in the app

Do note the wording — Giving AddItemViewController a direct reference to ChecklistViewController prevents you from opening the Add Item screen from somewhere else in the app.

The issue is the direct reference to ChecklistViewController - when you have a direct reference, then your AddItemViewController relies on ChecklistViewController being it’s parent and the parent always having specific methods (in this case an add method). So you can only use the AddItemViewController with ChecklistViewController because AddItemViewController is directly linked to ChecklistViewController.

If you wanted to use AddItemViewController with a different view controller elsewhere in your app, then you would have to change all the code which refers to ChecklistViewController (in the implementation for AddItemViewController) to point to the new view controller. But then, while AddItemViewController would work fine with the new view controller, it would no longer work with ChecklistViewController.

Does that make sense?

Struggling to understand that advanced topic which blows my mind .
Thx Fahim … I started to figure out some points. .

This topic was automatically closed after 166 days. New replies are no longer allowed.