cocoa - How do I use an NSFormatter subclass with an NSPopUpButton -


I want to use an NSFormatter subclass to format the contents of NSPopUpButton, I can display a list of options I am using. / P>

Actually I have an NSArray of MyObjects that is bound to NSPopUpButton through the content values ​​and I want to display something in the pop-up menu - given by donation. I really do not want to use a transformer because then I have to create a completely new array and change each object before adding it to the new array in a string.

Using SetFormatter: On either NSPopUpButton, either IB or code is not working, I suspect because only the personal cell format is applied to the items in the list.

Is there an easy way to set a format for all NSPopUpButton? Actually I just want to be able to set it up and forget about it.

Usually you want to bind your popup button in an array controller that contains custom model objects (Through content binding), and use the binding to specify a keypad with the string to use the content value as the title on those objects.

Which I think, you have an array of plain wire which you want to use as a data source, only you want to display a different string for the title, okay?

I'm not sure why data transformers will not work if set up as above - or maybe I'm doing something wrong? You have a binding for the actual string, and using a transformer is another binding for the string, but both of them will use the same array controller. Your other options are to create a model class to wrap around the string and provide a title property, or create a category on NSString that gives your headline to use as display value binding. In all these cases, you can create your own NSFormatter code and use it to return the correct string title.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -