On 14 May 2011, at 8:48 PM, koko wrote:

> Given a Tab Bar Application with n Tab Bar Items what is the recommended 
> pattern for the Views associated with each Tab Bar Item to communicate 
> between themselves?

Views don't communicate with each other under the MVC pattern. They communicate 
only with controllers. Controllers are free to communicate with each other, or 
(preferably) only with model objects that other controllers can observe.

In the project template for a tab-bar application, MainWindow.xib instantiates 
the application delegate and each tab's view controller. You can add IBOutlets 
to any of them that refer to any of the others. Once you've linked the outlets 
up in Interface Builder, your code free to send messages between them.

If you mean to share model objects, instantiate them in the XIB (or if they're 
dynamic, instantiate a broker object that creates, destroys, and indexes them) 
and have each controller refer to them directly, so that there is only one 
authoritative copy of any model object. The controllers can then use KVO or 
notifications to observe changes; if all the controllers observe model changes 
independently, they don't need to communicate directly at all.

        — F

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to