Join Harrison Ferrone for an in-depth discussion in this video Swift structs, part of Learning Swift 3 for Developers.
- [Narrator] Make some room underneath…our user one and user two,…and put in a new header comment, Swift Structs.…For our example structure,…we're going to create a game level data object.…We start of with the struct keyword.…We're going to call it Game Level,…and used the open and closed curly braces.…Our struct is going to have two constants,…let level ID of type Int,…and let level Description of type String.…
We're also going to have a variable called…is Current Level of type Boolean.…We're going to give it an initial value of false,…and finally we're going to have a read only property,…var debug Message of type String.…Use our curly braces and return Level,…level ID,…and then colon, and then level Description.…
Structs can also have…lazy, read write, and observe properties, just like classes.…However, structs come with a default initializer,…so you don't have to write an explicit one…unless you need to.…When we were talking about classes,…I mentioned that defining an instance of user class…as a variable or a constant, wouldn't effect…
- Starting a new playground
- Printing to the console
- Declaring variables
- Working with numbers
- Using strings
- Breaking down optionals
- Understanding closures
- Classes vs. structs
- Extensions and protocols
Skill Level Beginner
1. Hello Swift
2. Back to Basics: Variables and Operators
3. Collections, Tuples, and Enumerations
4. Working with Logic Flows
5. Only in Swift: Optionals
6. Functions, Closures, and Associated Types
7. Classes vs. Structs
8. Advanced Topics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.