Play with Extensions in Swift-3.0 ….

Why Extension is required in Swift ??

* Add new functionality to existing class,structure,enum or protocol
 * Add Computed Properties || Computed Type
 * Add instance methods and type methods
 * New initilizer for existing class .
 * Define Subscript
 * Add new Nested Type in existing type.


How to Add computed instance properties and type properties ??

i)Play with Computed instance properties

ii)Play with Computed type properties


How to Add instance methods and type methods ??

i)Add Instance Method

ii)Add Type Method


Why to Add new initializers in Extension ??

* To accept custom types as initializer parameters

Note : Extensions can add only new convenience initializers to a class, but they cannot add new designated initializers or deinitializers to a class.

How to Add new nested type ??

Common case study for Extensions in Project :-

i) Refract Converter of Existing Integer

ii)Replace New String with Smiley Face

iii)Creating New Color Method to return customize color

Access Control of Extension :-

Show your support

Clapping shows how much you appreciated Shrawan K Sharma’s story.