How do I add my own properties to the Bindings Inspector in Xcode?

169 views Asked by At

When editing a .xib in Xcode, I can select a view or other object, navigate to the "Bindings" tab in the Inspector, and bind its properties to properties of other objects. This is all well and good, but if I create my own subclass and add new properties, those properties won't appear in the list, and I'm having trouble finding an up-to-date solution for adding them.

I'm aware that I can create the binding at runtime using bind:toObject:withKeyPath:options:, but that doesn't seem like a very elegant solution, as it's clunkier than setting up a binding normally is, and adding glue code kind of defeats the purpose of using bindings. The only method I've seen is to create something called an IBPlugin, but I'm hearing Xcode stopped supporting IBPlugins ages ago when it and Interface Builder were merged into a single program.

So how can I do this? I tried @IBInspectable, which makes properties settable in the inspector, but it doesn't look like that makes them bindable.

0

There are 0 answers