For the More Curious: NSValueTransformer

Bindings read values from objects. Sometimes, a value will need some massaging before it can be used. To fulfill this purpose, Apple created NSValueTransformer. One example is NSNegateBoolean, which transforms true into false, and false into true.

The Hidden binding on views in Interface Builder is very convenient, as long as you are binding to a Bool that is true when you want the view hidden. If your Bool is true for shown, you can simply enter NSNegateBoolean in the Value Transformer field of the bindings inspector. No need to jump through hoops to create a bindings-compliant Bool for the inverse.

You can create your own NSValueTransformer subclasses and attach them to bindings in your ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.