Android App Development
iOS App Development
Flutter 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 126.96.36.199 release ready!
Updated 6 July 2023
In this blog, I am discussing how we can reduce a bunch of repetition code.
In old code structure, we use different storyboard and each storyboard contains multiple view controllers.
So moving from one controller to another firstly we have to create an instance of storyboards and create the reference of view controller from that we can push or present view controller over the current view controller and that same code we have to write in each class where we are moving from one controller to the another.
Here is the example of repetition which we usually used to write:-
As we all know in swift, we say enum class first last so with the use enum we create a number of case equal to the number of storyboards our project contains with their raw value(which refers their actual name):-
For moving one controller we need these things one is storyboard instance and another is view controller reference.
From storyboard raw value we can get storyboard instance and from View controller itself, we can get view controller’s identifier from them we can create there reference. so we can use generics to implement this feature in the enum:
How to use them:-
I hope from this, it will make you more comfortable dealing with different storyboards and view controllers. Thanks for tuning in once again!
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.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.