I’ve been developing everything with xib files because we needed to suport iOS4.
Now we are finally supporting only iOS5 and iOS6, so I decided to give storyboards a try, so everything is fine and easy, but I have found myself doing a lot of code like this:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"AddPlayer"]) { //Ugly
UINavigationController * navigationController = segue.destinationViewController;
PlayerDetailViewController * playerDetailsViewController = [navigationController viewControllers][0]; //Super Ugly
playerDetailsViewController.delegate = self;
}
}
I don’t know about you guys, but I found this code very ugly and error prone.
Is there a better way for working with Storyboards? Should I got back to xib files?
I worked with Storyboards quite a lot in the last app we built where I work and yeah, I agree the boilerplate code gets pretty annoying after some time, but as far as I know using
prepareForSegueis the only way to pass parameters when using segues.You can’t assign properties/delegates on a custom view controller from the Storyboard itself.
depends.
If I had to build a small – medium app (not too many views and not a lot of cross-navigation between them) I would definitely use Storyboards. But when you have a lot of views and a lot of back and forth navigation between them, it really gets complicated to keep the Storyboard nice and tidy, and it feels like you are forcing yourself to use something that actually isn’t the best.
On the other hand I feel Storyboards make it much easier to get a feel of the flow and general look of the app when starting from scratch, and you can even use them to create mock-ups that will actually look like the real thing.
So in essence it boils down to what your needs are when starting a project.
EDIT:
Another thing to take into account: if you use SVN/Git or any other VCS to work with a team, Storyboard file conflicts are a total bitch.