My question is slightly different then my title suggest. I have worked with xib. Now i am trying to work with storyboard. My question is if we are navigate through one class from another class, is StoryBoard giving benefit for better memory management. Suppose we have 2 ViewControllers: ViewControllerA and ViewControllerB. We are trying to go through ViewControllerA --> ViewControllerB. Now, in Xib our approach is below;
ViewControllerB *VCB = [ [ViewControllerB alloc] init]; [self.navigationController pushViewController: VCB Animated: YES];
Where in Story Board,
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"Second"]) { SecondViewController *objSecond = (SecondViewController*)[segue destinationViewController]; } }
And Do,
[self performSegueWithIdentifier:@"Second" sender:self];
So, My question is We alloc our class in Xib, Where in storyBoard we aren't. So is there any memory allocation advantages in storyboard?
Storyboards - this is a visual tool for laying out multiple application views and the transitions between them (segues). XIBs (or NIBs) - each XIB file corresponds to a single view element and can be laid out in the Interface Builder, making it a visual tool as well.
For most new developers coding on iOS 13 or higher, you should learn SwiftUI. If you need to maintain an older code base with Storyboards, you should learn Storyboards.
Storyboard Advantages over SwiftUIIt is easier to use Storyboard as a beginner . Storyboard consist of Xib and custom View which can be reusable in the projects. It is easier to build an app as there is only drag and drop of the elements of the storyboard.
In fact, the acronym "NIB" comes from "NeXTSTEP Interface Builder", and "XIB" from "Xcode Interface Builder". NIBs and XIBs are effectively the same thing: XIBs are newer and are used while you're developing, whereas NIBs are what get produced when you create a build.
My point of view that a professional developer MUST use xibs
, but a hobbyist, new to programming, developer might be helped if he uses storyboard.
Storyboard
After a 3 year project work with a single storyboard I can tell a lot of disadvantages
:
1) It REALLY gets VERY VERY slow to build even for a very very very little think ( every single view in it must be rebuild ). Also it is very hard to edit even with an iMac with 8 or 16 gb ram if the Storyboard gets bigger. It's even hard to open it.
2) No reusability. There is no way you can import immediately a View/ViewController with its view to another project. It will be connected with other ViewControllers, Views Or Segues and that will make it like a big "don't touch" think.
3) there is so much lag when the project gets bigger even for the smallest layout constraint to be added or edited, that you never want to touch it.
4) If you use the cells by automatic cell addition of storyboard, you cannot use the same cell build in two points.
Advantage:
1) Automatic Cells (But this is also a disadvantage because a cell cannot be reused as is to another view)
2) Segues etc would make it easy for someone to understand with a single point of view what is happening.
Xibs:
1) Fully portable.
2) Open/Edit/Build SO MUCH MUCH MUCH faster than a storyboard that gets bigger
conclusion:
If you are a hobbyist developer who will make an app for his business for fun, you should use storyboard because it will it easier to understand things. BUT, if you a professional developer, you MUST use xibs for VCs, Cells, etc, Because this is the only way to make them really reusable and portable, in order to gain so much time for the next project, or even when having to make a little change or build the storyboard again.
Explanation why xibs are more "reusable and portable" for me: Things in programming must be kept in different models, files, entities, modules. One must be as least dependent on another thing as it can get
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With