Should or should not use nib files ?

Luong Huy Duc picture Luong Huy Duc · Jan 14, 2012 · Viewed 8.1k times · Source

I'm new to iOS development. I've read through some of the source code I've found online and lots of them does not include a single nib file. All the view seems to be drawn manually from code.

What is the benefits of having/not having a nib file? Why did they choose to create everything from code instead of something you could visualize such as storyboard or *.xib files?

Answer

bryanmac picture bryanmac · Jan 14, 2012

The biggest reason I like code is it diffs well in source control. XIBs are very hard to diff, merge, read.

Code is also easy that copy/paste saved snippets. With IB, I always forget some check box which leaves me wondering why the magic isn't working. My notes have code snippets.

What IB really excels at is layout and helping you with human interface guidelines (number of pixels between controls etc... with guiedlines).

So, my personal preference is layout in IB and everything else in code (including target, action, adding columns etc... etc...). Under dynamic scenarios though, IB falls apart and you end up with custom views.

Here's a related post:

Interface Builder (XIB) or Code when merging in a team environment?