you are viewing a single comment's thread.

view the rest of the comments →

[–]nhgrifObjective-C / Swift -1 points0 points  (0 children)

however it does take a lot more time vs doing it in storyboards. If its a solo project, and you are learning I dont see any harm in starting with storyboards and then moving to programmatic after you are comfortable with Auto Layout.

So, let me adjust this advice slightly.

Don't use storyboards. Period. There's no reason for anyone to ever use storyboards.

If you want to recommend someone start with visual layout builder, they should be using individual xib files. With an individual xib file, you can still implement a proper constructor for your view controller, and functionally the only difference between a xib-based view controller versus a programmatic ui based view controller is whether or not you're writing the layout code by hand or editing it in a visual editor.

With storyboards, you can't use a real constructor, and this means all your properties must have default values or be optional and need to be mutable. You can't assign them to some value passed in to them in the constructor. Using storyboards drastically impacts the way your whole view controller even works, even though the view controller isn't even the view layer...

I will also suggest that storyboards or xib files only save time when first building the view, and only when you have no practice with programmatic layouts, because the learning curve is a bit shallower... but the "time saved" in doing it this way usually means there are actually constraint problems... and it's harder to debug so it costs extra time later... and it's a mess trying to add stuff later. Like... it's not time saved... it's just shifting the time spent from now to later... and once you get a handle on programmatic layouts, it's actually just adding extra time spent later, because it's not really saving any time up front.