How far can I go with referencing properties in IB?

Hello, it’s me again.

I’m just beginning to discover how much IB can lighten my coding, and I want to know how far it goes.

I have a text view in which I want to put alternatively two versions of a text (let’s say “long” and “short” versions).

No problem to put on a text after reading it from file: if I have this NSMutableDictionary named *theDict", with keys “longText” and “shortText”, I bind the “value” of textView to theDict.longText and it works divinely (not forgetting to put MY when something change inside the code part :/)

But I have a switch button to toggle between long and short version. So I want my referenced value to change accordingly to the value of this button (which is a property too).

Is there a way to add, in IB, a modifier to the Model Key Path? What is this Value Transformer? Is it possible to use it to switch between theDict.longText and theDict.shortText, using the value of the button?

Of course it’s easy to do it by code. That’s my present solution, and it works. But… I just wanted to know.


Shame on me, I’ve cheated.

I have created two different ScrollViews on my main window, exactly overlapping, and bound each of the text subviews to a different Model Key Path (say, gMyNSDictionary.longText and gMyNSDictionary.shortText). So for the contents.

Then I used the value of my switch button and bound it to the “Hidden” state of both scrollviews. For the first, Hidden is bound the value, and for the second, to the value with value transformer NSNegateBoolean.

It works, and I have a complete (double) text editor (RTFD) with reading/saving. for a dozen of lines of code. It’s just magic :cool:

It couldn’t have been possible without the help of programmers all around the planet. Long live MacScripters :slight_smile: