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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:56:06+00:00 2026-05-23T12:56:06+00:00

I have my shared user defaults plist that looks something like: menuItems (Array) Item

  • 0

I have my shared user defaults plist that looks something like:

menuItems (Array)
  Item 0 (Dictionary)
    name (String) "Menu Item 0"
    show (Boolean) NO
  Item 1 (Dictionary)
    name (String) "Menu Item 1"
    show (Boolean) YES

and so on.

I have an NSArrayController that has its content array bound to the shared user defaults controller with the Controller Key = “values” and the Model Key Path = “menuItems”. I have “Handles Content As Compound Value” enabled. It’s Object Controller Mode is “Class” and the Class Name it controls is NSMutableDictionary.

The desired outcome is for NSMenuItems “hidden” property to be bound to the “show” entries in the plist. You’ll notice, though, that “hidden” and “show” are opposites, so I created an NSValueTransformer that simply does:

return [NSNumber numberWithBool:!value];

I set up the binding as follows, where “item” is an NSMenuItem, “valueTransformer” is an alloc’ed and init’ed transformer as described above, and paneNum is the index where the proper dictionary can be found for the corresponding menu item:

NSDictionary *bindingOptions = [NSDictionary dictionaryWithObjectsAndKeys:
        [NSNumber numberWithBool:YES], NSContinuouslyUpdatesValueBindingOption,
        valueTransformer, NSValueTransformerBindingOption,
        nil];
    [item bind:@"hidden"
      toObject:[[defaultsController arrangedObjects] objectAtIndex:paneNum]
   withKeyPath:@"show"
       options:bindingOptions];

The binding seems to be working to a certain extent; menu items are initially shown or hidden, but the valueTransformer is never used and therefore the “hiddenness” of each menu item is backwards. (As an aside, if the plist changes, the menu items “hiddenness” is also not being updated automatically, as I would expect with bindings.)

What did I miss?

BTW, I realize that it would be easier to just store “hidden” instead of “show” in the plist, but at this point I want to understand why this isn’t working.

Edit: My guess is that it has something to do with the fact that I’m trying to bind to an object inside an NSMutableDictionary. If that’s the case, what’s the right way to do this?

  • 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-23T12:56:07+00:00Added an answer on May 23, 2026 at 12:56 pm

    I just ended up using NSNegateBooleanTransformerName (something I found today). I am going to assume there was something stupid in my value transformer or that it has to do with trying to bind to the NSMutableDictionary as a sample project I whipped up that didn’t use a dictionary worked fine.

    Edit: It was something in my transformer as NSNegateBooleanTransformer is working fine, even with the dictionary in the mix. (A conflict there wouldn’t have made sense, anyway).

    I’d love for someone to explain why a value transformer based on the code above (should be the same as NSNegateBooleanTransformer) doesn’t work, and I’d change my answer acceptance.

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

Sidebar

Related Questions

I'm storing font preferences for a WebView in my shared user defaults. I have
I have an NSArrayController instance bound to Shared User Defaults Controller. (see screenshot below)
I have a multi-user eclipse (3.4) installation with a shared master configuration area. Users
I have a shared library that I wish to link an executable against using
Assembly [AssemblyName] must have a shared name to be installed globally I am getting
We have various servers that have many directories shared. It's easy enough to look
I have some code that uses the shared gateway pattern to implement an inversion
I have two process and a shared memory zone, my workflow is like this.
I have an application that has an public 'end user' mode and a 'back
I have an application that is installed on Vista PC's by a user with

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.