Swift Object ModelLesson 33Free preview
Initializers
This lesson is part of Swift · All levels
Summary
This lesson reviews the Initializers in Swift who are tasked with preparing instances of class, struct, or enum to be ready for use before their properties are accessed. Swift applies the two-phase initialization rule that guarantees all stored properties are filled with valid values before another code is executed.
Key points
- Initiation is declared with the keyword 'init()'
- All stored non-optional properties must be initialized before the init process is completed
- Class distinguishes designated initialisers and convenience initialisers
- Failed Initializers ('init?()') can return zero if the initialization fails to meet data validation
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.