Proper use of controllers
Proper use of controllers
- Subject: Proper use of controllers
- From: "John A. Debay" <email@hidden>
- Date: Sun, 1 Feb 2004 23:53:25 -0600
Hi,
I have a quick question on how the new controller/binding layer fits in
with various objects' delegates. For example, in my application, I have
a standard master/detail interface very similar to the example in
Apple's documentation:
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Tasks/masterdetail.html
I have all of the user interface elements bound correctly to the model
through the controller layer, but am having trouble deciding where to
place certain functionality. For example, when the user is entering
data for a new table element into the detail view of my interface,
there are two or three fields that are required, so if the user tries
to save their changes with one of these fields blank, I need to throw
up an alert box and prevent the changes from being committed to the
model.
My first shot at this was to subclass the NSArrayController and
override methods like commitEditing or discardEditing. The problem is
that all of the controller methods are called frequently, and it is
hard to tell that a certain behavior is taking place simply because one
of these functions has been called.
Does this mean that I should be taking the traditional route of placing
this functionality in my window controller class, and only if the data
has been entered correctly by the user programmatically call the
NSArrayController's insert: method? More broadly, are people just using
the controller layer to automatically insert and display data, while
still employing custom window controllers to hold most of the UI
validation logic? Or are people moving most or all of this type of
logic into various NSController subclasses?
Any help that can be provided would be greatly appreciated.
John
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.