Consider the following general situation:
You have a MainView in a Cocoa application downloaded from an NIB that is controlled by a MainViewController . Your MainView contains some controls, such as UILabel infoLabel . You also have a MyDelegate delegate class that receives some kind of event.
You want to make sure that when MyDelegate receives its event, infoLabel updated accordingly. However, the problem is that MyDelegate does not have a link to the MainView or MainViewController and does not know about the label.
One solution is to pass the MainViewController link to the delegate object, but this seems to be wrong because you might be in an undesirable situation where the object has a link to each other.
What is the right design to solve this problem?
design objective-c cocoa touch
Jake
source share