What is a nib file

Source: Internet
Author: User

The nib file is a special type of resource file that holds the user interface for iphone OS or Mac OS X applications. The nib file is a interface builder document. You typically use Interface Builder to design a visual part of your application-such as a window or a view. Sometimes you might also use it to configure objects that are not visible, such as controller objects (for managing windows and views). In fact, all of these operations are editing a copy of the Interface Builder document, which is creating an object graph. When you save a file, you archive the object graph, and when you load the file, the object graph is unpacked.

The nib file-that is, the object graph-can contain placeholder objects that are used to refer to objects that exist outside the document. Although these objects are not in the document, they may contain references to objects within the document, or to objects within the document. The owner of the file is a special placeholder object.

You can use loadNibNamed:owner: (or variant of this method) to load the nib file while the program is running. In the nib file, the file owner is a placeholder object that represents the object that you pass to this method through the owner parameter. When the nib file is loaded, all associations established in Interface Builder (associations between the file owner and other objects) can be re-established at run time.

A nib file is a data file that stores some "frozen" objects that can be used when the application requires it. In most cases, the application uses the nib file to store the Windows and views that make up the user interface. When you load a nib file into an application, the nib load code translates the contents of the file into real objects that the application can manipulate. With this mechanism, NIB files eliminate the work of creating those objects with code.

Interface Builder is a visual design environment that you can use to create nib files. You can place standard objects (such as Windows and views provided in the Uikit framework) and custom objects in the Xcode project into the nib file. Creating a view hierarchy in Interface Builder is fairly straightforward and requires just a simple drag-and-drop on the image object. You can also configure the properties of each object through the viewer window and define their relationship at run time by creating a connection between objects. The changes you make will eventually be stored on disk as part of the nib file.

At run time, when you need the object contained in the nib file, the nib file is loaded into the program. Typically, the time to load the nib file is when the user interface changes and some new views need to be displayed on the screen. If your application uses a view controller, the view controller automatically handles the loading process of the nib file, and you can, of course, load it yourself through the methods of the class.

Main NIB File

Another task to initialize is to load the application's main nib file. If the application's Information property list ( Info.plist ) file contains NSMainNibFile a key, the UIApplication object mounts the nib file specified by the key as part of the initialization process. The main nib file is the only nib file that is automatically loaded, and the other nib files can be loaded later as needed.

The nib file is a disk-based resource file that is used to store snapshots of one or more objects. The main nib file for the iphone application typically contains a Window object and an application delegate object, and may contain other important objects for one or more administrative windows. Loading a nib file causes the objects in the file to be reconstructed, transforming the disk representation of each object into a memory object that the application can manipulate. There is no difference between objects that are loaded from the nib file and objects that are created programmatically. However, for the user interface, it is often easier to create objects that are associated with the user interface in a graphical manner (using the Interface Builder program) and store them in the nib file than in a programmatic way.

What is a nib file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.