Extensions in iOS

Updated 31 March 2021

Save

Extensions in iOS provide help to add the new functionality of an existing class, structure, or enumeration type.

But overriding the functionality is not possible with extensions.

Extensions in iOS works the same as a category in objective-C.

So extension provides help for confirming the protocol.

Writing of extension is very simple and we can create an extension outside of class.

Extension syntax

-> We can do the below things using the extensions.

A->  Add compute instance and type work properties.

B-> We can create the type and instance method.

C-> Extension provides the new initializer.

D-> We can define subscripts and nested features.

The extension can adopt more than one protocol.

Computed Type Property

The extension can add computed type and computed instance property.

we can create multiple functionalities then compute and get the results.

so we can create a computed property from the above step.

=> Methods

We can create multiple methods in extensions according to our requirements with multiple types.

This will help us to use this method anywhere with the same datatype.

=> Initializer

Initializer use to provide the new and custom initialization of the existing type.

So This enables you to extend other types to accept your own custom types as initializer parameters.

=> Subscripts

Extension provides a feature that adds a new subscript for an existing type.

This example provides us the string character according to the given index.

And thanks for reading this blog, for detail info please click here

For more blog please click here.

So pls follow the above step and And if you have any issue or suggestion you can leave your message in the comment section I will try to solve this.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home