In Objective-C, all objects are at the top level and are given a global scope. They can be said to be in the same namespace. This is one reason for the convention among Objective-C developers, including Apple, of prefixing their class names with two- or three-letter identifiers.
These prefix characters allow similarly named classes from different frameworks to be differentiated, for example, UIView from UIKit and SKView from SpriteKit. Swift solves this problem by allowing types to be nested within other types, providing namespacing with nested types and modules.
Any type can be defined as being nested within another type. This allows us to tightly associate one type with another, in addition to providing namespacing, which helps differentiate types with the same name. In this recipe, we will create some nested types to see if it affects how they are referenced.
How to do it...
Let's build a system to monitor a physical device and the user interface...