Why code instead of IB?
There are several reasons why we may need, or choose, to create a user interface in code, rather than using Interface Builder:
- It may be necessary to configure the interface according to runtime criteria. The user may perhaps be given a choice of how the interface is presented, for example, or the number of some UI elements may depend on data that cannot be foreseen at compile time.
- Code is easier to read than a storyboard. To find out all the property values of an interface built with Interface Builder requires endless clicking on the various panes and inspectors. Reading through the same properties set in code, on the other hand, will generally entail no more than scanning over a few classes.
- Code shows structure. The interaction and relationships between the various elements of the interface are written explicitly into the code, with no behind-the-curtains magic being supplied by the IB development team.
- To code it is to understand it. However adept we may become at...