I don’t think it’s so awful a question. Lot of folks responded negatively to the “best” aspect of the question. A simple rephrase might be “what circumstances are best suited for each kind of inter-object communication”.
In summary the common ones are as follows:
- Direct invocation (google Objective-C language methods) – Most
common, most direct, tightly collaborating objects.
- KVO (google “Objective-C KVO”) – for a particular object to observe a particular
value change in another.
- NSNotification (google “NSNotification”) – for a any/many interested objects to observe any event another object wants to broadcast
- Delegate (google “Objective-C delegate”) – when an object requires work to be done on it’s behalf by some other object, it publishes a delegate protocol. Other objects can implement this protocol (“conform to it”) and then be assigned as the delegate. (this one overused, in my opinion)
There’s tons of web material on how to implement each (google them for details).
solved ios different ways of calling a method from different classes [closed]