Designated vs Convenience vs Failable init (Init Types in swift)

1. Default initialiser 2. Custom initialiser

Designated init:

Convenience init:

  • Designated init may or mayn’t call another designated init.
  • If you’re using inheritance, Subclass designated/convenience init should call Superclass Designated init method.
  • Convenience init can call another convenience init or designated init.
  • But finally your convenience init/designated init should finally call super class designated init.

Failable init:

Advantages of Failable init:

  • If you know that you can’t create the instance of object by using data provided by you, instead of creating an instance you can return nil.
  • This returns an optional instance that will be nil if initialization failed.




iOS Developer in walmart

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Takeaway from serverless computing in AWS

Git Basics

Follow-up to the AMA Session of April 20th 2022 — Community Report

Point Inspection

Notes From The Oral History Of Bjaerne Stroupstrup

Map() , Filter() , Reduce() and Lambda Function in Python

Journal 99 — Unity 2D Mobile, Dungeon Escape Set Up Spider & Skeleton

Higher Order Functions in Python.

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
Manasa M P

Manasa M P

iOS Developer in walmart

More from Medium

iOS Dev: Difference between frame and bound, the easiest explanation you can find nowhere

The Power of UICollectionView Compositional Layout | Swift | UIKit

Swift Essentials| A Complete Guide to Swift Operations

Phantom Types in Swift