Samhan Salahuddin
Samhan Salahuddin

Reputation: 2170

Coordination between classes in Cocoa

I have a program with a lot of controllers which need to co - ordinate with each other . I'm confused about which mechanism to use . What are the pro and con of using :

Specifically is there any problem with using notifications all over place ? I'm planning to do that as it allows a class to just put out some information and not bother about anything else.

Upvotes: 1

Views: 33

Answers (1)

yfrancis
yfrancis

Reputation: 2616

Use delegates if you want your object to have knowledge of specific methods to call when it needs to inform an observer of a state change. Notifications are more appropriate when you have multiple observers. Both of these require manual intervention, i.e. you need to explicitly call the delegate methods or post notifications when state changes.

Bindings and KVO work hand-in-hand, and are automatic ways to update state in one object (e.g. UI) when state in another object changes.

Upvotes: 1

Related Questions