• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Switching NSArrayControllers around
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Switching NSArrayControllers around


  • Subject: Switching NSArrayControllers around
  • From: Knud Hinnerk Möller <email@hidden>
  • Date: Tue, 20 Mar 2007 12:06:37 +0000

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Switching NSArrayControllers around
      • From: Brian Smith <email@hidden>
  • Prev by Date: Re: Debugging Core Data unresolved keypath save error
  • Next by Date: Re: Detecting when menubar is visible
  • Previous by thread: Re: How to detect main menu being opened
  • Next by thread: Re: Switching NSArrayControllers around
  • Index(es):
    • Date
    • Thread