Beware of Interface Builder! [For Beginner: YES]
I just realise that Interface Builder sometimes can be so annoying for a programmer. For a beginner, it can be useful since it provides a way that another development doesn’t give this such convenient way to build a software UI. For Xcode lover, this is one of the most loved features in iOS (currently me) development. Or actually, hated so much.
Why do I say that? Am I have a bad experience with this feature? Or I am a professional or even more, an expert, who starting to build my UI in custom UIView subclasses with the mess of Autolayout code (hahaha)? No, I am not. I am just a typical beginner who gets a bad time with a new tool. And it is a tool which I am going to use every day as long as my programming career in iOS development. Waiting someone create a new IDE which will compete with Xcode and AppCode? An opensource is just an option. But a powerful one is a must.
So, let’s discuss why does Interface Builder with all of its convenience tool become a sign of (bad) programmer if they depend on it.
This is my experience from Thursday until Friday morning only to find that I just missing my attention to a checkbox which turns my UICollectionViewCell become hidden from my Window and UI Hierarchy.
The story is I was writing a code and designing UI with Xcode. So far so good. Nothing bad happen for 3 weeks until the time I included a UICollectionView to my FooViewController. I decided to build the UICollectionViewCell in a separate XIB file. When I was complete, I ran the application and find that the new cell didn’t show up in my collection view hierarchy. What? Why? I’ve repeated the same thing in other ( 5 ) ViewController and nothing such problem happens. To be clear. I just included a simple cell which I am going to edit it later. Yes, it just a placeholder. But now the result is not what I desired.
The first thing I do is inspecting my code which declare how Cell will be displayed. But so far, nothing changed because I just reuse the other code from another working ViewController. I want to blame the code, I get nothing!
I decide to change the Cell to another working cell. That guess what happens, it was working very well!
Then I spent some minutes later to compare both Cells and eventually I find that a checkbox has been marked YES while it should be NO. This a property which declares will a UIView be displayed or not. You know, because it must be assigned every time you are playing with UIView, isHidden property.
Back to Interface Builder. I don’t know why that Hidden property is checked while I never consciously checking the cell to be hidden. Maybe at some point, I do this while editing some value or someone did the bad job to me, I don’t know. But it opens my mind that Interface Builder can be so very annoying just because of this property. A programmer who doesn’t know or experiencing this issue will go deep to the hole of advanced debugging while the thing that they should care is just isHidden property which consciously assigned if they build the View from inside ViewController. Maybe next time Apple should add a new feature in UI Debugging to display each UIView regardless of their property and provide a search feature or information on currently selected item state. Bad English eh? Yup, I am learning. :D