Structs are used almost everywhere in Swift:
Array and even
Bool are all implemented as structs, and now you can recognize that a function such as
isMultiple(of:) is really a method belonging to
Let’s recap what else we learned:
struct, giving it a name, then placing the struct’s code inside braces.
willSetproperty observers to properties inside a struct, which is helpful when we need to be sure that some code is always executed when the property changes.
SPONSORED Join a FREE crash course for iOS devs who want to become complete senior developers — from October 18th to 24th. Learn how to apply iOS app architecture patterns through a series of lectures and practical coding sessions.
Link copied to your pasteboard.