Initializers in swift part-3: Required Initializers in swift

Required initializers will be explained in this article.

Here is the first part of this article series: Initializers in swift part-1 : (intro, convenience and designated intializers)

Image for post
Image for post
//required initclass classA {required init() {var a = 10print(a)}}class classB: classA {required init() {var b = 30print(b)}}//______________________let objA = classA()let objB = classB()prints:
class classC: classA { }
let objC = classC() // prints 10 ..superclass init method gets called.

If you enjoyed reading this post and found it useful, please share and recommend it so others can find it 💚💚💚💚💚💚 !!!!


Written by

iOS and tvOS developer, dreamer, photographer 🤨

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store