• 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
Re: Core data, NSArrayController and different nibs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core data, NSArrayController and different nibs


  • Subject: Re: Core data, NSArrayController and different nibs
  • From: Cathy Shive <email@hidden>
  • Date: Thu, 6 Nov 2008 11:45:50 +0100

On Nov 6, 2008, at 8:50 AM, Tomaž Kragelj wrote:

It looked so trivial at the start, but didn't work as expected - my single window application uses the following setup:

- MainMenu.nib: my AppController and all the NSArrayControllers with bindings set properly so when an item is selected in the master controller, it's details are handled by children controllers (all data comes from managed context).
- MainWindow.nib: the main window with placeholder view (and the rest of the common user interface).
- CustomView.nib: the actual views are implemented each in a separate nib and are then moved as child view in the main windows placeholder when necessary (similar to Apple's ViewController sample).


The problem I have is that the custom views need the data from the array controllers defined in MainMenu.nib. It seemed logical to create outlets to the array controllers in my AppController and expose them through accessors to the rest of the controller layer.

Something like this should work :)

In my custom views I would then bind the controls to these (like Application.delegate.arrayController.arrangedObjects.key for example). But this doesn't work - the bindings are ok, there's no error, but I get no data.


The custom view here is a table view, right? I'm just guessing, but if this is the case, then I think the issue is that NSTableView wants (neeeeds) to be bound to an array controller - not the app delegate - even if the key path leads it to an array:
http://www.cocoabuilder.com/archive/message/cocoa/2008/7/17/213304


In this post, it is suggested that Ivy put her array controller back in the nib with the view ;) That is exactly the opposite of what your trying to do with your refactoring project. Someone else suggests using a proxy array controller as you've described.

I'd just do the binding in code so that you can maintain the design you're after until someone fixes this "bug" with NSTableView (I call it a bug, the key path should be good enough for the view to establish the binding!) Anyway, it's just one line of code vs. setting up more array controllers.

So my next try was to add "proxy" array controllers inside the custom view nibs and bind their content array to the file's owner representedObject (which is set manually to the corresponding array controller before the nib is loaded - like [viewController setRepresentedObject:[[NSApp delegate] arrayController]]). This works, but selection in master array controller is not propagated to the custom view proxy child controller. Furthermore, if I release the custom view and create it again, the contents are empty (it only works the first time).


Maybe this thread is related? http://www.cocoabuilder.com/archive/message/cocoa/2008/4/7/203452

I am at the moment refactoring my application from single nib to above structure. All was working when the views were living in the same nib as array controller! Am I missing something here?

I'd like to stick with the first alternative (but need to get it working first...) - without going through proxy controllers. It looks cleaner. Is this the right design choice?


I think that whether it's the right design choice is debatable, maybe at this level, it's just a matter of personal preference :)


Best,
Cathy

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: Core data, NSArrayController and different nibs
      • From: Tomaž Kragelj <email@hidden>
References: 
 >Core data, NSArrayController and different nibs (From: Tomaž Kragelj <email@hidden>)

  • Prev by Date: Re: Enumerating outlets automatically?
  • Next by Date: Re: How can I use NSTextField like a button?
  • Previous by thread: Core data, NSArrayController and different nibs
  • Next by thread: Re: Core data, NSArrayController and different nibs
  • Index(es):
    • Date
    • Thread