What are the benefits of using Storyboards instead of xib files in iOS programming?
Solution 1:
A Storyboard is:
- A container for all your Scenes (View Controllers, Nav Controllers, TabBar Controllers, etc)
- A manager of connections and transitions between these scenes (these are called Segues)
- A nice way to manage how different controllers talk to each other
- Storyboards give you a complete look at the flow of your application that you can never get from individual nib files floating around.
- A reducer of all the "clutter" that happens when you have several controllers each with it's own nib file.
I have been using Storyboards for awhile now and the ONLY downside is that you can't target iOS 4 or below. Storyboards only work on devices running iOS 5 or better. Other than that, the benefits are many and the downsides are non-existent IMO.
The best tutorial I have seen is Ray Wenderlich's
Also, if you are a member of the Apple Developer program, check out last years WWDC session on Storyboards (iTunesU), it is awesome.
Another great one (also on iTunesU) is the latest Stanford iOS Application Programming course.
Solution 2:
There are not only pro sides of Storyboarding, also cons - just because you asked for input:
- it's not easy to work with SBs in a team, since only one participant can work on the SB at once (because it's one file).
-The following is not true: - if you need to do things SB doesn't offer, it's not quite easy to get SB mixed with programatical created views (well, it is possible though)
The rule of thumb seems to be: the more complex you expect your project to get, the more you'll better not go for SB.
EDIT: - another disadvantage of SB: working around all the annoying bugs of XCode regarding SB. E.g. having to frequently flush the DerivedData folder because of several inconsistencies. Sometimes storyboard files or the link to them get corrupted. Then you might have the joy to search for the problem. Take a look at this thread to get the idea
EDIT 2 (March 2013): meanwhile Storyboards and Xcode are working much better, and documentation and best practices are wide spread. I think working with storyboard can be recommended for a majority of projects, even if there are still some glitches.
EDIT 3 (Sept 2013): now with the new Xcode 5 format working in teams with SB might get even better, as it seems to become possible to merge SB-code much easier now.
Another EDIT: well, if you have an hour of time, sit back, relax and listen to these guys discussing this topic (Ray Wenderlich & Co)
Edit 2016.1: after a long time being a Storyboard advocate, I had so much hassle with it the last months, that I decided to abandon Storyboards as far as possible. The reason for that is that Apple adds feature like stupid, but doesn't care about the bugs and the flaws. The performance having a lots of auto layout constraints is really bad (while design time), and the error-prone-ness has become huge. Example: even less complex Storyboards tend to get into a 'dirty mode' right after opening a project in Xcode (see git state). Tip: as a beginner you will love Storyboards since you can prototype quickly and get things running without lots of code. As you enter an intermediate state, you'll add more GUI code to your project. Now you start going back and forth between code and SB - and things start working out worse. Sooner or later you'll tend to do most of the GUI stuff in code, because the result is more predictable than having several sources.