Slow performance when using NIB files?

I am curious to know if anyone has experience comparing the loading performance of iPhone applications with the views set forth in NIBs and the views set out completely programmatically (e.g. creating a UITextView, adding it to the view, creating an instance of UIButton, adding it to the view .. .).

If I want a simple application to load lightning fast, would it be better to abandon the use of NIB (ok, XIB technically) and create presentation program elements instead? Is the time taken to download and parse the NIB sufficient to make a noticeable difference?

+4
source share
2 answers

I noticed that loading complex interfaces on iPhone with NIB is a bit slower. This is only a split second, but it is noticeable if the user expects to see a sheet or modal view. I believe that the difference is that NIBs are downloaded to the iPhone, so the view is created the first time the view is viewed, and not the first time the controller and view hierarchy are created. However, this probably only matters on the iPhone :-)

In general, I would say that NIBs always face any performance flaws that may exist. I wrote iPhone apps back when the SDK came out and Interface Builder was not well tested. Writing code to create a hierarchy of views was a terrible mess ...

+5
source

In my experience, it makes no noticeable differences at all.

And if you are thinking about what happens with the NIB system, this is a compact binary representation of the state of user interface objects. By creating an object programmatically, you save only the time required to download this file and perform very simple parsing. Compare this with the amount of time it takes to initialize and make the first draw of this object (allocating memory for the underlying CALayer objects, drawing them using Quartz2D, and then combining the results together). This time is much longer, and it is exactly the same whether you use NIB or not. If you download a bunch of PNG files to draw your user interface, it will overshadow the time spent on creating controls.

+4
source

All Articles