On Jun 18, 2011, at 10:43, Kevin Muldoon wrote:

> I have an NSTable which receives its dataSource from MyTableController.m. 
> However, my AppController.m needs the data MyTableController.m holds. Since 
> AppController.m hasn't explicitly instantiated MyTableController 
> (MyTableController being an NSObject within IB with appropriate delegates and 
> such) how does AppController.m access MyTableController.m data?

Well, you're torturing the MVC paradigm, and it's fighting back.

A data source is a delegate-style object, but it's not really intended to 
"contain" the data. The data source extends the behavior of a controller 
object; the data should be in a data model. It's certainly *permissible* to 
merge the two, but that's for the case where the controller is the only thing 
that needs the data -- which isn't this case.

As a generic problem, though, it's not that hard. If object A creates object B 
which creates object C, and object A needs to access object C, then clearly B 
must have a public interface that returns a pointer to C. In other words, 
object B should have a property whose value is a pointer to C.

But based on your description, don't use this solution in this case. Create an 
actual data model._______________________________________________

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