Define structures with properties and initialize new instances. Understand how to work with default memberwise initializers. Learn how to create designated and convenience initializers.
- Structures are value types,…so they're copied when assigned to a variable or constant…or passed to a function.…Structures are used all over the place in Swift.…Case in point,…all the basic data types in swift…including strings, integers, doubles,…arrays, dictionaries and more are structures.…The syntax to define a structure…is to write the struct keyword,…followed by the name,…and then curly braces enclosing its body.…Structure name should begin…with a capital letter and use camel casing…in multi word names.…Structures can have properties and methods…at both type and instance levels,…and instances can have subscripts.…
Structures have initializers…and they can be extended or adopt protocols.…They don't have a de-initializer though…and they cannot inherit.…Now I'll define a new structure…which will be used to create 3-D coordinate instances.…I'll add X, Y, and Z integer properties…and a label string property.…I've made the integer properties constants…and the label a variable.…Remember that constants can be assigned once…
Learn how to write code, understand Swift's key concepts and best practices, and strengthen your programming problem-solving skills. Instructor Scott Gardner teaches the fundamentals, so you'll be prepared to develop applications for iOS, macOS, and other platforms. Completing this course will enable you to not only write first-class code, but to think like a Swift developer.
- Creating playgrounds
- Defining variables and constants
- Working with characters and strings
- Working with collections and groups
- Using operators and defining custom operators
- Controlling program flow
- Defining functions and closures
- Working with classes, structures, and enumerations
- Adopting protocols
Skill Level Beginner
1. Get Started
2. Variables and Constants
3. Characters and Strings
4. Collections and Tuples
6. Control Flow
- 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.