A look at a few somewhat lesser-known ways in which enums can be used to solve various problems in Swift-based apps and libraries.
A summary of all Swift by Sundell content published during April 2020.
Swift enums are really powerful, but they can often be made even more capable when mixed with other kinds of Swift types — such as protocols and structs. This week, let’s take a look at a few examples of doing just that.
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.