Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10
Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 22.214.171.124 release ready!
Owner and Founder. Opencart
The primary initializer for a class is a Designated initializer. It initializes all the properties of a class and calls a superclass initializer to continue the initialization process. Whereas Convenience init is a secondary initializer of a class. In the same class, we can define a Convenience initializer to call a designated initializer. It is not necessary to provide a Convenience initializer, if it is required then only we will use it.
The syntax for Convenience init is:
According to swift doc, there are three rules that simplify the relationships between designated and convenience initializers.
1 -> A Designated initializer must call a designated initializer from its immediate superclass.
2-> A convenience initializer must call another initializer from the same class.
3-> A Convenience initializer must ultimately call a designated initializer.
Let’s see an example of using Convenience init.
In the above example. We have created a Person class. In the Designated initializers we have initialized the name with the value “none”. Now we have created a convenience init with a parameter salary. So, now when we use convenience init then it confirms that all the properties must be initialized, by calling the Designated init. So, in this way, we do not have to write the initialization code again.
Thanks for reading this blog.
You can also check other blogs from here. If you have any issues, queries, or suggestions then you can leave your issues/queries/suggestions in the comment section.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.