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

  • Home
  • SEARCH
  • 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 6909063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:38:30+00:00 2026-05-27T08:38:30+00:00

I have a tree controller bound to an array, called content. content is an

  • 0

I have a tree controller bound to an array, called “content”. “content” is an array of model objects, called “Car”. Each “Car” contains an NSString called “carName” and an NSMutableArray called “mostPopularColors”. “mostPopularColors” contains NSMutableDictionary objects with keys like: “most popular”, “second most popular”, “third most popular” etc and values like: “red”, “green”, “blue” etc.

An outline view is bound to the tree controller arranged objects and displays the “carName” of every “Car” in “content”. A separate table view lists every “carName” in one column. This is done by having an array controller bound to the tree controller (controller key: selection, model key path: allChildLeafs).The table column value is then bound to the array controller’s arranged objects, model key path: carName.

In the table view, I want two other columns listing the most popular color and second most popular color respectively. So the final table should have three columns listing all the car names along with each car’s two most popular colors.

I can access the car names as described but not the colours since they themselves are in arrays.

I have tried to make a second array controller and link it to the first but can’t get it to work.

So in the end I want to be able to select a car or cars in the outline view and see all their names and top two colors of each in the table view.

  • 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-27T08:38:31+00:00Added an answer on May 27, 2026 at 8:38 am

    It seems the second array controller did not work because it isn’t possible to connect two array controllers to one table view.

    The array controller that was bound to the tree controller (controller key: selection, model key path: allChildLeafs) was left in place but not bound to any view.

    In Xcode an IBOutlet NSArrayController was created and then connected to a newly created array controller in Interface Builder (IB). Also, an new NSMutableArray was declared, with setter and getter methods. Then, the following code was used to bind the array controller to the new NSMutableArray:

    [newArrayController bind:NSContentArrayBinding toObject:self withKeyPath:@"mutableArray" options:nil];
    

    So now the array controller would “hold” whatever was in the new mutable array. The contents of the array could be displayed in a table view by connecting the new array controller to a table view.

    All that was needed was to make this mutable array contain an NSMutableDictionary object for each car. Each dictionary would have three key value pairs. The three keys would be: “carName”, “mostPopularColor”, “secondMostPopularColor”.

    Since the old array controller held the array of “Car” objects currently selected in the outline view, this was done by first getting that array of “Car” objects. To do this, changes in the old array controller’s arrangedObjects were observed and the new array of “Car” objects were observed using:

    [oldArrayController addObserver:self forKeyPath:@"arrangedObjects" options:NSKeyValueObservingOptionNew context:nil];
    

    To handle the observation and use the new array of “Car” objects to get the final array of dictionary objects the following method was implemented:

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context  {if (object == selectedChildLeafsController)
    {
        if ([[object arrangedObjects] count] > 0)
        {//make a new mutable array, here called "array", of dictionaries from your array of "Car" objects which is found in [object arrangedObjects] . And then something like...
        [self setMutableArray: array];
        [newArrayController bind:NSContentArrayBinding toObject:self withKeyPath:@"selectedBonds" options:nil];}else
    {
        [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
    }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tree that consists of several objects, where each object has a
Using: Rails 3.1.1 I have a controller/model/view called Category that is built up on
I have a tree of active record objects, something like: class Part < ActiveRecord::Base
I have a tree data structure that is L levels deep each node has
I have a NSTreeController which array is bound to a items (custom) property of
I have a Course model with 2 associations to another model, Tree: belongs_to :interaction_outline,
I have a tree of Zone objects: class Zone { protected Zone $parent; public
I have tree control object created using CTreeCtrl MFC class. The tree control needs
I have tree tables, Customer, Invoice and InvoiceRow with the standard relations. These I
I have a tree structure in memory that I would like to render in

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.