Swift creates default initializer for Structures If we don’t write any for stored properties.
If we write our own initializer like shown below, The default one will be gone.
If we need both the default and the one we write, We can take the advantage of Extensions in Swift.
Just move your init method to extension. That’s it.
Now you can have both the default and your customized init methods.
Hope this post is useful, Feel free to comment incase of any queries.
No comments:
Post a Comment