Updated for Xcode 14.2
Structs are used almost everywhere in Swift: String
, Int
, Double
, 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 Int
.
Let’s recap what else we learned:
struct
, giving it a name, then placing the struct’s code inside braces.mutating
.didSet
and willSet
property 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 From March 20th to 26th, you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.