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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:58:39+00:00 2026-06-12T04:58:39+00:00

I don’t know if what I see with a popup button populated by bindings

  • 0

I don’t know if what I see with a popup button populated by bindings with a value transformer is the way it’s supposed to be or not — the unusual thing I’m seeing (at least with respect to what I’ve seen with value transformers and table views) is that the “value” parameter in the transformedValue: method is the whole array bound to the array controller, not the individual strings in the array. When I’ve done this with table views, the transformer is called once for each displayed row in the table, and the “value” parameter is whatever object is bound to that row and column, not the whole array that serves as the content array for the array controller.

I have a very simple app to test this. In the app delegate there is this:

+(void)initialize {
    RDTransformer *transformer = [[RDTransformer alloc] init];
    [NSValueTransformer setValueTransformer:transformer forName:@"testTransformer"];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    self.theData = @[@{@"name":@"William", @"age":@"24"},@{@"name":@"Thomas", @"age":@"23"},@{@"name":@"Alexander", @"age":@"64"},@{@"name":@"James", @"age":@"47"}];
}

In the RDTransformer class is this:

+ (Class)transformedValueClass {
    return [NSString class];
}


+(BOOL)allowsReverseTransformation {
    return NO;
}

-(id)transformedValue:(id)value {
    NSLog(@"%@",value);
    return value;
}

In IB, I added an NSPopupButton to the window and an array controller to the objects list. The content array of the controller is bound to App Delegate.theData, and the Content Values of the popup button is bound to Array Controller.arrangedObjects.name with the value transformer, testTransformer.

When I run the program, the log from the transformedValue: method is this:

2012-09-19 20:31:39.975 PopupBindingWithTransformer[793:303] (
)
2012-09-19 20:31:40.019 PopupBindingWithTransformer[793:303] (
    William,
    Thomas,
    Alexander,
    James
)

This doesn’t seem to be other people’s experience from what I can see on SO. Is there something I’m doing wrong with either the bindings or the value transformer?

  • 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-06-12T04:58:40+00:00Added an answer on June 12, 2026 at 4:58 am

    Unfortunately, this is how NSPopUpButton works. The problem is not limited to that control. If you try binding an NSArrayController.contentArray to another NSArrayControllers.arrangedObject.someProperty you will get the same problem. Here is a simple workaround that I use in all my value transformers, which makes them work with both tables and popups:

    You can modify your value transformer in the following way:

    -(id)transformedArrayValue:(NSArray*)array
    {
        NSMutableArray *result = [NSMutableArray array];
        for (id value in array)
            [result addObject:[self transformedValue:value]];
    
        return result;
    }
    
    -(id)transformedValue:(id)value
    {
        if ([value isKindOfClass:[NSArray class]])
            return [self transformedArrayValue:value];
    
        // Do your normal-case transform...
        return [value lowercaseString];
    }
    

    It’s not perfect but it’s easy to replicate. I actually put the transformedArrayValue: in a class category so that I don’t need to copy it everywhere.

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

Sidebar

Related Questions

Don't know how to google for such, but is there a way to query
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't these two mean the same thing, first get the value and then increment?
Don't know why people do not practice AJAX implementation for authentication systems. Is it
I don't know if this question is trivial or not. But after a couple
Don't know if I'm over-thinking this or not.. but I'm trying to be able
Don't know if there is a better way to do this, so that is
don't know if the title describes anything about what I'm trying to say but
don't know what happened in my jcrop selection. I think I pressed some keys

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.