The Question is this :
I have a view controller Controller 1 which is a delegate of 2 other controllers Controller 2 and Controller 3.
Controller 2 has a delegate method called “FOO”, Controller 3 has the same method.
Can I implement one “FOO” method inside Controller 1 if both “FOO” methods tells the delegate to do the same exact thing ?
Thanks
Shani
Good delegate design means methods shouldn’t have the same name. For example, if I have two classes called
FooAandFooB, that both perform the delegating actionfoobar:(BOOL)force, then the delegate method names should be as follows:This way, your ‘Controller 1’ will be able to differentiate between the two delegate methods. You will notice this in other delegates, for example
UITableView:You’re able to differentiate if
shouldHighlightRowAtIndexPathoriginated from aUITableViewor a different class.Saying this, it is entirely possible to have a single method name shared between two delegates, it’s just the delegate won’t be sure of the source of the delegation.