flâneur — a map of the web's best reading

Property wrappers in Swift | Swift by Sundell

swiftbysundell.com · 3,147 words · saved by 1 readers

This article has been archived, as it was published several years ago, so some of its information might now be outdated. For more recent articles, please visit the main article feed. When dealing with properties that represent some form of state, it’s very common to have some kind of associated logic that gets triggered every time that a value is modified. For example, we might validate each new value according to a set of rules, we might transform our assigned values in some way, or we might be notifying a set of observers whenever a value was changed. In those kinds of situations, Swift 5.1’s property wrappers feature can be incredibly useful, as it enables us to attach such behaviors and logic directly to our properties themselves — which often opens up new opportunities for code reuse and generalization. This week, let’s take a look at how property wrappers work, and explore a few examples of situations in which they could be used in practice. Like the name implies, a property wrap

This article has been archived, as it was published several years ago, so some of its information might now be outdated. For more recent articles, please visit the main article feed . Property wrappers in Swift properties language features Swift 5.1 Published on 19 Jan 2020 Basics article available: Properties When dealing with properties that represent some form of state, it’s very common to have some kind of associated logic that gets triggered every time that a value is modified. For example, we might validate each new value according to a set of rules, we might transform our assigned value

Explore this link on the map →

related reading