On Sep 18, 2010, at 7:59 PM, Paul Johnson <p...@askerko.net> wrote:

> I'm really unclear on how to structure my program, in particular the
> controllers.  In IB I dragged a 'Window and Drawer' to the document window.
> In the drawer I have a Table View, and I have another Table View in the Main
> Window. I want to be able to drag a selection from the Drawer to the Window.

Okay, this means some object will need to be the drawer's table view's 
delegate, some object will need to be the window's table view's delegate, and 
these objects will need to be able to communicate with each other.

Typically, the table view's data source (or NSController if using bindings) 
also serves as the delegate, simply because that's the most convenient 
solution. As you get more experience, you'll start to have a good gut feeling 
about when you should double up responsibilities like this.

> I expect the program to grow in complexity and I want to take that into
> account from the beginning.

Cut and paste are very fast operations. Since you are certainly using some 
version control software, if you find that your architecture is making your 
life difficult, it's perfectly safe to head down an experimental path of moving 
code around.

In other words, you need to get over your fear of not doing it right the first 
time, especially if you're learning. Remember, you cannot predict the future.

(Certain people reading this message might recognize this as advice I need to 
be reminded to follow myself.)

> I am using Core Data to model the data for the Drawer's Table View and for
> the Document's Table View. (I have two models.)
> 
> 
> My question is, how should I created the Controller file(s). Should I create
> separate controller files for the Drawer and Main Window?

Don't think of them as "files." Files are just the places you put the code that 
defines classes.

If it makes sense to give different names to the type-of-thing that drives your 
drawer's table view and the type-of-thing that drives your main outline view, 
then it's probably a good idea to make them separate classes.

If, instead, it makes more sense to refer to them both as the same 
type-of-thing with slightly different behavior, then it makes sense to use two 
instances of the same class, perhaps behaving slightly differently under the 
direction of parameters.

It sounds like the first case is what you have on your hands.

> In general, does anyone have any guidelines on how one "partitions" the
> controller functions into files?

The best advice in this matter is well-written source code. You should be 
constantly reading a lot of code. Find people to discuss this code with. Your 
local NSCoder Night branch (http://www.nscodernight.com) is a great place to 
start.

Good luck, and happy coding!
--Kyle Sluder_______________________________________________

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