سؤال

After doing some reading I notice Apple pushes the use of delegates on controllers communicating with one another.

So say I have a Menu controller which needs to communicate with the help controller (and they need to share info - lol don't ask me why they would). I could do this through delegates, but why use delegates when I can pass the required information on through a help object and have the help controller pick back up this info that was changed in the previous controller.

Delegates still couples - however loosely it may be, wouldn't the use of objects be the best practice here for re usability?

هل كانت مفيدة؟

المحلول

Delegates are great for responses, especially if the response isn't going to be immediate.

If you're simply telling the help controller something like what information to display, passing it directly is great. If you want to know, for example, when the help controller is done displaying help for the user a delegate is clearer and usually superior.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top