What is the difference between convenience init vs init in swift, explicit examples better
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Swift classes, init usually means a designated initializer, while convenience init means a secondary initializer that delegates to another initializer in the same class. The distinction matters because Swift enforces explicit initialization rules for inheritance. Once you understand which initializer is responsible for creating the full stored state, the difference becomes much easier to remember.
Designated Initializers Do the Real Setup
A designated initializer is the initializer that makes sure the class’s stored properties are initialized and that superclass initialization is completed.
Here Car.init(model:) is designated because it initializes model, the property introduced by Car, and then calls a designated initializer on the superclass.
A designated initializer always delegates upward with super.init(...) once the subclass has initialized its own stored properties.
Convenience Initializers Are Shortcuts
A convenience initializer is a secondary entry point. It does not finish object setup on its own. Instead, it must call another initializer from the same class.
convenience init() is a helper. It provides an easier way to create a Car, but it still relies on the designated initializer to do the actual setup.
That is the core difference: designated initializers build the object, convenience initializers route callers to a designated initializer.
The Delegation Rules Matter
Swift enforces three simple rules for class initialization:
- a designated initializer must call a designated initializer from its superclass
- a convenience initializer must call another initializer from the same class
- eventually, every initialization path must reach a designated initializer
Those rules prevent half-initialized objects and make inheritance behavior predictable.
Why Structures Do Not Use convenience
This distinction applies to classes, not structs. Structures do not have class inheritance, so they do not need the same designated-versus-convenience model.
This looks similar to a convenience initializer, but in a struct it is just another initializer. There is no convenience keyword because there is no superclass chain to manage.
When to Use Each One
Use a designated initializer when the initializer is responsible for creating the real stored state of the class.
Use a convenience initializer when you want:
- default values
- a shorter calling style
- a helper path that translates one set of parameters into another
A convenience initializer is a wrapper. A designated initializer is the actual constructor path that guarantees the object is fully initialized.
Common Pitfalls
- Assuming every
initin a class is automatically just a simple constructor with no delegation rules. - Trying to call
super.initdirectly from a convenience initializer. - Using
convenience initwhen the initializer actually needs to initialize new stored properties. - Forgetting that structs do not use the same designated-versus-convenience distinction.
- Writing several overlapping initializers without one clear designated path that owns the real setup.
Summary
- In classes, a designated initializer performs the real object setup and delegates upward to the superclass.
- A convenience initializer is a helper that delegates across to another initializer in the same class.
- Every initialization path must eventually reach a designated initializer.
- '
convenience initis mainly for shortcuts, defaults, and alternate argument forms.' - Structs can have multiple initializers too, but they do not use
conveniencebecause they do not inherit from superclasses.

