It seems that people may ask: is this view built from a nib
. Is it true that a nib
is the compiled form, and xib
is in XML form, and we don't use nib
any more but only use xib
? So nowadays, it just means "is it built from a xib"?

- 3,770
- 6
- 41
- 62
-
3As far as I'm concerned, they're the same thing. – CodaFi Apr 22 '12 at 05:41
2 Answers
iOS development has never actually used .nib files. It's always been .xibs. NIB was originally an acronym for NeXT Interface Builder. iPhone development originally used a tool called Interface Builder to create user interfaces, saved in .xib format. Interface Builder has recently been (sort of) merged into XCode 4, so you can build your .xib files there.
Yes, the .xib format is a human-readable XML format, which makes it a little easier to use with version control systems (diffing, etc.) than .nibs.
For legacy purposes, I suppose, the two formats are pronounced the same ... "nib". Probably also because words that start with "x" are difficult to pronounce :)

- 31,017
- 13
- 83
- 207
-
1No, the iPhone has ***always*** had nib files. As the OP stated, nibs are compiled (or rather, flattened) XIB files. – CodaFi Apr 22 '12 at 05:51
-
You're not answering a question posted by a compiler. You're answering a question posted by a human .. presumably a developer. Developers have no practical visibility into nib files for iPhone. It's only .xib files, and there's every reason in the world to expect that this is what the poster is asking about. When someone talks about a view being "built from a nib" on iOS, they absolutely mean that it was instantiated from a user interface document, originally laid out in a .xib file. – Nate Apr 22 '12 at 06:35
-
And I am merely saying that it is absolutely false to claim iOS ***"never"*** had XIB files. – CodaFi Apr 22 '12 at 06:36
-
I assume you mean NIB, but regardless, I clarified my comment. I was never referring to what the OS itself was doing under the hood. I acknowledge that out of context, the term "iOS" could be construed to mean solely the operating system itself, and not the general app development ecosystem. Again, I point you back to the poster's context, which is unlikely to be asking about hidden operating system files, vs. the files developers normally see. – Nate Apr 22 '12 at 08:12
I disagree completely with @Nate's answer. IOS has in fact always had nib files, they've just been hidden. You see, when the compiler flattens a XIB file so that it can be retrieved by the application, it actually "converts" it to a .nib file! If you don't believe me, try this:
NSLog(@"%@", [[NSBundle mainBundle]pathForResource:@"myxib" ofType:@"xib"]);
It returns NULL, because it doesn't exist! Now try this:
NSLog(@"%@", [[NSBundle mainBundle]pathForResource:@"myxib" ofType:@"nib"]);
Pretty cool, huh?
So in a twisted way, it is correct to say that a XIB is really a nib.

- 43,043
- 8
- 107
- 153
-
That's a rather contrived example, that misses the context provided in the poster's question. Nobody ever uses that code in an actual program. In the rare cases where you do access nib/xibs programmatically, you're more likely to encounter them via something like - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil ... which does not need an extension at all (.xib or .nib). – Nate Apr 22 '12 at 06:39
-
Ah contraire. I am developing an application which allows the editing of XIBs (which is the sole reason I answered), so it is not as rare as you'd think, which is dodging the overall question itself. Conceptually, they are equivalent. – CodaFi Apr 22 '12 at 06:41
-
Because you are doing something unusual means it's **not** rare? Please look at the context of the poster's question. This is an entry-level question, and is very unlikely to be posed by someone trying to edit nibs programmatically, rather by a new iOS developer who wants to understand why people say "nib", but all they see in their workspace are .xib files. Or maybe they used to develop for Mac with old versions of Interface Builder, before they went to the XML .xib format. Either are vastly more likely than your use case. – Nate Apr 22 '12 at 08:05
-
As I have stated afore, sir, my use case, no matter how rare or exotic it might be, is not at fault nor at issue here. If rarities were the basis of programming, then a lot of the C language would be trivialized. In any matter, I have provided an answer as I saw fit to the question, yet it disagrees with yours. If you wish to discuss this further, I shall have no objections about going into a chat room. – CodaFi Apr 22 '12 at 08:13