Which is more efficient way? StoryBoard or XIB?

Vishal Sharma picture Vishal Sharma · Mar 20, 2014 · Viewed 27.9k times · Source

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?

Answer

Giorgos Ath picture Giorgos Ath · Apr 21, 2015

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