UIView root layer and setting sublayers to 'nil'

As a library that is integrated in to 3rd party applications, we sometimes come across situations where bad or incorrect use of the core iOS frameworks can make Reveal appear to make the hosting application misbehave, or at the very worst, crash.

When you create a CALayer, its sublayers array property is nil by default.

When you create a UIView it creates a root CALayer which is used for rendering, and exposes it via the layer property. This layer also has a sublayers array property, however it is pre-populated with layer instances necessary to render the view to screen.

If you set a view layer's 'sublayers' property to nil, the view's root layer can no longer access sublayers that it depends on. It is analogous to randomly removing subviews from one of your own view hierarchies - at best, things won't look right — at worst your app will crash.

We recommend that you not set any layer's 'sublayer' property to nil.