Apple document says:
A nib file is a special type of resource file that you use to store the user interfaces of iOS and Mac apps. A nib file is an Interface Builder document. You use Interface Builder to design the visual parts of your app—such as windows and views—and sometimes to configure nonvisual objects, such as the controller objects that your app uses to manage its windows and views. In effect, as you edit an Interface Builder document, you create an object graph that is then archived when you save the file. When you load the file, the object graph is unarchived.
The nib file—and hence the object graph—may contain placeholder objects that are used to refer to objects that live outside of the document but that may have references to objects in the document, or to which objects in the document may have references. A special placeholder is the File’s Owner.
At runtime, you load a nib file using the methodloadNibNamed:owner:or a variant thereof. The File’s Owner is a placeholder in the nib file for the object that you pass as the owner parameter of that method. Whatever connections you establish to and from the File’s Owner in the nib file in Interface Builder are reestablished when you load the file at runtime.
iOS uses nibs as an implementation detail that supports storyboards, the iOS user interface design layout format. Storyboards allow you to design and visualize the entire user interface of your app on one canvas. For iOS developers, using storyboards is the recommended way to design user interfaces.
構(gòu)建項(xiàng)目時(shí)象浑,所有的XIB文件都會(huì)被編譯成NIB文件(NIB文件體積更小,更容易解析)蛉加,然后Xcode將NIB文件拷貝到應(yīng)用的程序包(bundle)别瞭,程序包其實(shí)就是目錄,其中包含應(yīng)用可執(zhí)行文件和其所用到的所有資源嗡髓。
應(yīng)用在運(yùn)行時(shí)刻會(huì)從程序包中按需載入NIB文件并激活文件中的對(duì)象混滔。
https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/NibFile.html#//apple_ref/doc/uid/TP40008195-CH34-SW1