Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Switching NSArrayControllers around



Hi,

I have two NSArrayControllers and and NSTableColumn. Depending on some other factors (what is selected in another table), I want to change which of the controllers is shown in the table. So far I'm doing this by changing the bindings of the table column. That works fine, but it is a little messy, because there are actually also other UI elements that need to be changed accordingly (add and remove buttons for the table, textfields that display details of the table selection, ...). I currently have to change bindings for five different UI elements each time.
Here is my question: can I somehow always have the table column (and all the other UI elements) be bound to the same array controller, and simply change the content of that controller? My naive approach (that didn't work) was this:


- the app delegate exposes a controller "combinedResourceController"
- in IB, I bind the table colum to that controller like so: appDelegate.combinedResourceController.arrangedObjects.anyLabel
- in the app delegate, I let the combinedResourceController var point to either of the two resource controllers, depending on the situation. E.g.:


- (void)tableViewSelectionDidChange: (NSNotification *)notification
{
   int row = [[notification object] selectedRow];
   if (row == 0)
      combinedResourceController = allResourceArrayController;
   else
      combinedResourceController = resourceArrayController;
}

Is this a step in the right direction? If so, what is missing to make this work (so far, nothing shows up in the UI)? If not, what should I do instead. Basically, I would like to reduce the amount of code and manual binding to a minimum.

Cheers,
Knud

-------------------------------------------------
Knud Möller, MA
+353 - 91 - 495086
Digital Enterprise Research Institute
  National University of Ireland, Galway
Institiúid Taighde na Fiontraíochta Digití
  Ollscoil na hÉireann, Gaillimh


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.