Factory method with block
Group outlets in a custom NSObject
Move every outlet to an NSObject. Then drag an Object from the library to the controller scene of the storyboard and hook the elements there.
Initialize attributes in didSet
It's also possible to both set a value and initialize it:
Initialize with positional constants
Initialize with then
This is similar in syntax to the example that initializes using positional constants, but requires the
Then extension from https://github.com/devxoul/Then (attached below).
Set to tuples to avoid code repetition
Avoid code repetition in constructors by setting a tuple of variables with a one liner:
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0