Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
233 views
in Technique[技术] by (71.8m points)

ios - Which is more efficient way? StoryBoard or XIB?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...