On Jan 13, 2017, at 09:52 , Charles Srstka <cocoa...@charlessoft.com> wrote:
> 
> What does NSObjectController do? Well, not a lot, but what it does is pretty 
> helpful:

There’s one other obscure thing that NSObjectController does (or did, since I 
don’t know if this situation still exists, but I doubt the bug will ever be 
fixed). When you bind a text field directly to an undoable model property, the 
undo chain gets messed up after certain combinations of undo and redo. There 
are actually two undo chains involved, because the window maintains an internal 
undo chain for typing which is grafted onto the top of your app’s undo chain 
while editing is in progress. For some reason, binding through a 
NSObjectController eliminates the problem in most cases.

There are a few other things that NSArrayController can usefully do that you 
didn’t mention explicitly:

— As well as shadowing the table view’s selection, it provides markers that 
represent “multiple selection” and “no selection” that Cocoa bindings are aware 
of.

— It supports the more intricate set of bindings that (say) NSPopupButton uses 
for its menu items’ checked and enabled states, and item text. Some of these 
things, if used, are required to be bound via array controllers.

— It has a standardized mechanism for handling validation errors, including the 
display of an error dialog.

In general, NS…Controller classes are glue classes that support the behavior of 
Cocoa bindings. That means, in general, when you use bindings, it’s desirable 
to bind via a NS…Controller for consistent UI behavior.

(OTOH, NS…Controller classes are horrible, inscrutable black boxes. But that’s 
a different rant.)

_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to