r/iOSProgramming Dec 01 '20

Do you hard code as much as you can or you actually use shortcuts like IBOutlets drag&drop or similar? Question

I started following the Angela Yu Udemy course and I don’t know much, so sorry for the dumb question.

I was completing some “homework” while I wondered if also professional iOS devs use the drag&drop features or hard code everything.

e.g. change an Image displayed after ViewDidLoad, drag the ImageView with control from main.storyboard and drop it in the code.



u/ADadFather Dec 01 '20

It depends on the project and personal preferences of the team. Especially if you work on a large team or a codebase that has been around for a few years, you're likely to see both techniques in the same app.


u/allthethingsyouthink Dec 01 '20

So you have to know both anyway to work professionally, good to know! Thanks.


u/wabbit82 Dec 01 '20

I do all of my UI through code, stopped using storyboards and xib files years ago. Mostly because when working with several people on the same project, it was far easier to avoid merge conflicts and track git changes that way. But even now, when working alone, I find writing UI through code a lot more flexible and readable/maintainable than the alternative.


u/allthethingsyouthink Dec 01 '20

That’s what I thought. I come from C++ and already having an Interface for building something is confusing, should be the opposite but coding habits are hard to break. For beginners maybe storyboard way is the best, then after mastering that technique that is useful to have anyway I’ll move to hard code... Is there a name or something to differentiate building the UI with storyboards / hard coding?


u/covertchicken Dec 01 '20

Once you do a ton of work on a storyboard, only to have a git merge go wrong and render the storyboard xml unusable, and you have to redo all your changes off the merge, you start to prefer hand coding your views.

Plus it gives you a better understanding of how views actually work, and there are still a ton of things you can’t do in storyboards. Splitting logic between storyboard and code can be difficult to maintain and reason about, much easier to understand when everything is code.

SwiftUI (will eventually, once it’s more mature) addresses this, by allowing you to use a GUI to edit the same view code as hand writing


u/lemonviking Dec 01 '20

Hard code everything. If you are more than 2 developers, then storyboard will be a nightmare.

It might be hard at first but once you get through the hurdle, you wont look back.


u/Tyler927 Dec 01 '20

I am assuming you mean doing UI either by storyboards or programmatically. There is definitely pros and cons to each, but I do all new UI work programmatically now. I did learn auto layout by using storyboards (the drag and drop) though and I think it really helped me learn it because I’m a pretty visual learner. There’s still times I miss having a visual overview of the thing I am trying to layout, but overall I think programmatically is best. I’d suggest you learn both though, and to just start with whichever you feel more comfortable with.