Join Harrison Ferrone for an in-depth discussion in this video Swift classes, part of Learning Swift 3 for Developers.
- [Instructor] I'm going to close out of Chapter Six,…and go up to the Xcode Navigator, and create new playground.…I'm going to name our new playground Ch7_ClassesAndStructs.…I'm going to save it into the Swift3ForDevelopers folder,…and hit Create.…Delete the default string and the comment,…and let's add our own.…Chapter Seven, Classes vs. Structs.…
And this video is Swift classes.…For our class example, we're going to model…a simple user object, and go through the various ways…of structuring Swift properties and initializers.…Let's start by making a new class,…by typing the class keyword,…and we're going to call this UserClass.…Open and closed curly brackets.…Let's give it a firstName string variable,…with an empty string, and an age of type integer,…with a default value of zero.…
Let's add a constant called userConstant.…This is going to be an optional string,…and we're going to give it a nil value for default.…Classes in Swift need an initializer,…so that's what we need to set up next.…Use the init keyword, open parentheses,…
- 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?
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.