Member-only story
10 Powerful @Attributes in Swift
Understand how to use the attributes correctly and efficiently
@escaping
It’s normally used as an escaping
closure passed as a function argument. It exists in the memory when the function ends and then gets executed.
When defining an optional closure as a property, it’s already escaping by default.
The escaping closure can be stored for later use:
Or it can be executed after the function ends:
@unknown
@unknown
was introduced with @frozen
and @nonfrozen
enumerations. A non-frozen enum may gain new enumeration cases in the future. For instance, the UILayoutConstraintAxis
contains two axes at the moment: AxisHorizontal
and AxisVertical
:
It may gain another case axisZ
later:
To safely avoid the compile error:
error: switch must be exhaustive