NEW: Nominations are now open for the 2019 Swift Community Awards! >>

DAY 9

Structs, part two


As you’ve seen, structs let us combine individual pieces of data to make something new, then attach methods so we can manipulate that data.

Today you’re going to learn about some of the more advanced features of structs that make them more powerful, including access control, static properties, and laziness. Yes, laziness – Bill Gates once said, “I choose a lazy person to do a hard job, Because a lazy person will find an easy way to do it.” In Swift, laziness is an important performance optimization, as you’ll see.

As a reminder, all of these things are used extensively in SwiftUI, so it’s worth taking the time to master them now because they’ll be in use from our very first project onwards.

Today you have six one-minute videos to watch, and as always once you’ve completed each video there’s a short test to help make sure you’ve understood what was taught.

  1. Initializerstest
  2. Referring to the current instancetest
  3. Lazy propertiestest
  4. Static properties and methodstest
  5. Access controltest
  6. Structs summarytest

That’s another key Swift topic under your belt – good job! Now do the smart thing and post your progress online: it forces you to write about these things in your own words, and also encourages you to continue on to tomorrow.

Need help? Tweet me @twostraws!

100 Days of SwiftUI


The 100 Days of SwiftUI is a free collection of videos, tutorials, tests, and more to help you learn SwiftUI faster. Click here to learn more, or watch the video below.

Back to 100 Days of SwiftUI