Quick Notes: Designated Init vs Convenience Init

“It was the rainbow gave thee birth, and left thee all her lovely hues.” — W.H. Davies

Designated Initializer (delegates up 🆙 )

  • default initializer
  • typically there is only one in a class
  • but there definitely has to be one at least !!
  • seen as a funnel point

Rules 📏

  • designated init must call super class’ designated init! (inheritance)
  • designated init must delegate up! ⬆️

Convenience Init (delegates across)

  • secondary / supporting init
  • has the keyword ‘convenience’

Use Case 🧰

  • provide default values for some initializers
  • specific use case

Rules 📏

  • delegates across: must call another init in the same class!
  • ultimately must call a designated init!

--

--

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
Navati

Navati

iOS dev eager to learn + advocate for unrepresented folk in tech. Engaged & empowered in community as Leadership Fellow @ WomenWhoCode Mobile + WTM Ambassador.