Enums
How enums work in Swift, a look at some of their most prominent features, and examples of situations in which they can be incredibly useful.
Weekly Swift articles, podcasts and tips by John Sundell.
How enums work in Swift, a look at some of their most prominent features, and examples of situations in which they can be incredibly useful.
With each new release, Swift keeps getting better and better at creating compiler-generated implementations of common boilerplate. One such new feature in Swift 4.2 is the new CaseIterable protocol - that enables us to tell the compiler to automatically synthesize an allCases collection for any RawRepresentable enum. This week, let's take a look at some examples of scenarios in which this new feature can come very much in handy.
Gathering some form of analytics from users can be cruicial when building, iterating on and improving a product. Learning how users use our app in real-life situations can sometimes be really surprising and take its development in new directions. This week, let's take a look at how an analytics system can be architected and implemented based on enums.
While switch statements are hardly something that was invented as part of Swift, they are made a lot more powerful when combined with Swift's type system. This week - let's go further beyond switching on single enum values and take a look at more of the powerful capabilities that switch statements offer in Swift.