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 6364443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:09:51+00:00 2026-05-25T00:09:51+00:00

Context: I have an NSArrayController tied to Core Data that supplies rows for an

  • 0

Context:

I have an NSArrayController tied to Core Data that supplies rows for an NSTableView. When a user selects rows, the arrayController’s “selectedObjects” property changes.

Now, each of those “selectedObjects” is a Core Data entity called “LPFile” that has an attribute called “style”, which is an integer from 0 to 3. The “style” attribute should correspond to the selectedIndex of an NSPopUpButton.

My Question:

If a user selects multiple rows AND the LPFiles associated with these rows have the same value for “style”, I would like the NSPopUpButton to set its “selectedIndex” property to that value. If the rows’ objects have DIFFERENT values for “style”, then the NSPopUpButton should display a blank row. (When the user then chooses a style, that blank row should disappear from the NSPopUpButton.)

I know how to achieve this by writing code manually and if selection was limited to a single row I could set up those bindings, but how do I set up the bindings to handle multiple selected objects that may or may not have different values for “style”? I’ve Googled quite a bit, but can’t find specific info and I’m tired of experimenting! (Note: I provide the content items for the NSPopUpButton in IB, so I don’t bind anything to the content bindings of the button.)

  • 1 1 Answer
  • 1 View
  • 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-25T00:09:51+00:00Added an answer on May 25, 2026 at 12:09 am

    You’ll probably have to write a little bit of code, but you can still use bindings to control the UI elements, in this case the popup button.

    Here is one way to do it that has worked for me:

    In the controller that provides the content for the array controller, define a property which contains the selection index set corresponding to the selection in the table view. Bind it to the array controller’s selection index set, so it is always updated and sync’ed with the table view. For simplicity, I have called it fileSelectionIndexSet in the following.

    Then, define a property that provides the index for the popup button. Below, I have called it styleIndex.

    You can bind the popup buttons selection index to this property. You may have to provide its content from the controller, too. That would be a readonly property returning a static array of strings, for instance.

    // Header file, just synthezise in implementation
    @property (retain) NSInteger styleIndex;
    

    Register the controller as an observer of its own fileSelectionIndexSet property:

    // It doesn't have to be awakeFromNib, any method will do if called before
    // you need the functionality
    -(void)awakeFromNib
    {
        [self addObserver:self 
               forKeyPath: @"fileSelectionIndexSet" 
                  options:NSKeyValueObservingOptionNew 
                  context:NULL];             
    }
    
    
    - (void) observeValueForKeyPath:(NSString *)keyPath
                           ofObject:(id)object
                             change:(NSDictionary *)change
                            context:(void *)context
    {
        if ( [keyPath isEqualToString: @"fileSelectionIndexSet"] ) 
        {
            NSInteger index;
            index = ... // Compute value based on current LPFile selection
            self.styleIndex = index;
        }
    }
    

    Implementing self as an observer of its own property makes the styleIndex property a one-way dependant of the fileSelectionIndexSet.

    This means that whenever the user changes the selection in the table view, the popup button is updated. However, when the user changes the selection in the popup button, nothing is changed in the table view.

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

Sidebar

Related Questions

I've a document-based application powered by Core Data with an in-memory store. I have
Context: I have a photo-uploading website set up. I need to perform operations on
First some context: I have an MVC3 .net project which, for the sake of
Suppose I have an SConstruct file that looks like this: env = Environment() env.Program(a,
I have created branches for one project, but now I have a need to
I've asked a similar question, but I've given up on the idea I had
First, Is it possible to find out what is the monitor frame/refresh rate in
Rewriting an html element's content, or itself is easy via jquery, but is it
I'm trying to detect if a point is within an gwt-g2d shape. Does anybody
I am currently working on the linqtotwitter library. I am using cookies to store

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.