Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 645989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:33:47+00:00 2026-05-13T21:33:47+00:00

I am having an issue wrapping my head around how to hook up a

  • 0

I am having an issue wrapping my head around how to hook up a few NSArrayControllers across two view controllers. I want to sync the selection in the source list table view to update the values in the second detail view controller.

I’m using the Cocoa Dev Central Build A Core Data Tutorial as the starting point, but have broke down the architecture so that there is an NSWindowController that contains two NSViewControllers: one for the posts table on the left and one for the post details on the right.

The NSWindowController subclass has an NSArrayController that is bound to the Post entity and a read-only managedObjectContext accessor that points to [[NSApp delegate] managedObjectContext]

I then initializing the two view controllers in the windowDidLoad method.

- (void)windowDidLoad
{
  static NSInteger kSourceListViewIndex = 0;
  static NSInteger kDetailViewIndex = 1;

  self.postsListsViewController = [[MDVCPostsListViewController alloc] initWithWindowController:self];  
    NSView *sourceListSplitViewContentView = [[self.splitView subviews] objectAtIndex:kSourceListViewIndex];
  NSView *sourceListView = [self.postsListsViewController view];
  [sourceListView setFrame:[sourceListSplitViewContentView bounds]];
  [sourceListView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
  [sourceListSplitViewContentView addSubview:sourceListView]; 

  // And now let's load the detail view.
  self.postDetailViewController = [[MDVCPostDetailViewController alloc] initWithWindowController:self];
    NSView *detailSplitViewContentView = [[self.splitView subviews] objectAtIndex:kDetailViewIndex];
  NSView *detailView = [self.postDetailViewController view];
  [detailView setFrame:[detailSplitViewContentView bounds]];
  [detailView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
  [detailSplitViewContentView addSubview:detailView]; 
}

MDVCPostsListViewController has an NSArrayController bound to the Post entity and its managed object context bound to the parent window controller’s managed object context (all through Interface Builder)

MDVCPostDetailViewController has an NSObjectController bound to the window controller’s managed object context and the content object bound to the window controller via postsListsViewController.postsArrayController.selection. This seems like a really sucky hack.

How can I get it so that changing the selection in MDVCPostsListViewController‘s table view will update the selected values in MDVCPostDetailViewController? I feel like I’m close, but am not sure what’s missing or what is the best route to take. I do feel that the postsListsViewController.postsArrayController.selection binding is extremely hacky. Hopefully there’s a better way.

I’ve uploaded my sample project that exhibits this for those that prefer to look at code rather than just read descriptions. You can grab it from my site at http://www.secondgearsoftware.com/attachments/stackoverflow_objectcontroller.zip

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:33:47+00:00Added an answer on May 13, 2026 at 9:33 pm

    How do you expect each window controller to discover the main window controller?

    From a quick glance at the project, it seems you just added an instance of MDVCMainWindowController to each NIB. These will be separate instances from the one actually running the main window.

    You need to bind your source list table selectionIndexes to the the Post array controller. Otherwise the selection will not be known at the controller level.

    I would suggest moving the array controller up into the main window controller. In your windowDidLoad method you could then pass it down to both the list and detail view. The list would bind to arrangedObjects and selectionIndexes, the detail view would bind to selection.someKey.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with my regex. I want to capture <% some stuff
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I'm having an issue with a Flash/Flex erroring in Firefox but not IE. I
I’m having an issue where a drop down list in IE 6/7 is behaving
I am having an issue where Tomcat is treating extra path information as part
I'm having an issue with a standard ASP.NET page that has a TextBox and
I'm having an issue with CruiseControl.net where the web dashboard just won't work in
I'm having an issue with expressions within reports. I'm coloring the background of a
I'm having an issue dragging a file from Windows Explorer on to a Windows
I'm having an issue setting up one of my projects in TeamCity (v4.0), specifically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.