3
\$\begingroup\$

I don't know whether this sort of thing exists (yet) outside of Xcode/ObjC/Swift... but if it doesn't already, surely it will soon.

But with Xcode 6, we can set up classes as "IBDesignable" and give them "IBInspectable" properties. The result is, when we make a element on the interface builder a custom class that is marked as IBDesignable, the interface builder itself will render the object as it would be drawn if you were to compile and run this code. But it does this without you running your full application.

Moreover, with the IBInspectable properties, through interface builder we can set runtime attributes for the object, such as border color, or whatever. This is different from setting a default value for the property as you might have done before. I can set these properties individually per object (of this same type). Interface builder renders the object with the effects of this property in mind, and when I run my application for real, it will also render the object with the same properties.

To this end, Apple has even introduced a method, prepareForInterfaceBuilder and a pre-compiler directive, TARGET_INTERFACE_BUILDER that allows the user to write code that will never be executed by the real application, but that the interface builder can use to set up a preview of the object.

This is actual working code. And some of it is code that will actually be executed by the real app (for example, drawRect is the method used every time the UI wants to refresh your object, but interface builder also executes this method). But more importantly, for at least me, there's a definite urge to want my interface builder code to work and look really good. If I develop a library of UI objects that I want to distribute to developers, I can make that library significantly better by giving them live-rendered previews of the objects they're playing with right in interface builder so they don't have to go through the effort of compiling their app then getting to the scene that has this custom object just to see how it looks.

I think a tag for this sort of code might be appropriate. It would certainly be applicable to and questions using IBDesignable in Xcode. It could be applicable to questions involving the XML for an Android layout. Beyond this, I'm not sure of any currently existing IDEs that will do live rendering like Xcode is doing now, but I'd be surprised if we didn't start seeing it more (if it's not already out there--I don't know).

As an example of a question that this tag would be appropriate for: IBDesignable UICheckbox

\$\endgroup\$
3
  • \$\begingroup\$ If it helps… we currently have layout. We have questions awkwardly tagged with android xml layout. Stack Overflow has android-layout and ibdesignable. \$\endgroup\$ Commented Nov 7, 2014 at 23:34
  • \$\begingroup\$ I'm aware of ibdesignable. There's also ibinspectable on Stack Overflow. I wasn't sure if those were good here or not. "IB Designable" seems to make sense for what we're talking about, but it's also exactly the ObjC/Swift keyword for designating a class that works in this way... I'm not sure if other languages/IDEs word work this way. layout doesn't seem very good. There's also user-interface which is used in the example question I linked (while layout is not). \$\endgroup\$
    – nhgrif
    Commented Nov 8, 2014 at 1:21
  • \$\begingroup\$ Ultimately, with the sort of question I have in mind, the actual compiled application running of the UI object is important, of course, but the idea here is that how a developer is able to interact with that element in IB is equally important, either because the code is code that will be reused numerous times in the writer's codebase, or because the writer intends this as part of a 3rd party framework to make available to other developers. \$\endgroup\$
    – nhgrif
    Commented Nov 8, 2014 at 1:24

1 Answer 1

2
\$\begingroup\$

I'm not aware of another language that uses this paradigm (although, that could simply be my own ignorance). So, I would just create the Tag. If (when?) other languages pick up on the concept it can be addressed with a synonym of whatever is decided describes the generic concept.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .