An object that wraps, or contains, Interface Builder nib files.


class UINib : NSObject


A UINib object caches the contents of a nib file in memory, ready for unarchiving and instantiation. When your application needs to instantiate the contents of the nib file it can do so without having to load the data from the nib file first, improving performance. The UINib object can automatically release this cached nib data to free up memory for your application under low-memory conditions, reloading that data the next time your application instantiates the nib. Your application should use UINib objects whenever it needs to repeatedly instantiate the same nib data. For example, if your table view uses a nib file to instantiate table view cells, caching the nib in a UINib object can provide a significant performance improvement.

When you create a UINib object using the contents of a nib file, the object loads the object graph in the referenced nib file, but it does not yet unarchive it. To unarchive all of the nib data and thus truly instantiate the nib your application calls the instantiateWithOwner:options: method on the UINib object. The steps that the UINib object follows to instantiate the nib’s object graph are described in detail in Resource Programming Guide.


Creating a Nib Object

init(nibName: String, bundle: Bundle?)

Returns a UINib object initialized to the nib file in the specified bundle.

init(data: Data, bundle: Bundle?)

Creates a UINib object from nib data stored in memory.

Retrieving Objects from the Nib File

func instantiate(withOwner: Any?, options: [UINib.OptionsKey : Any]?) -> [Any]

Unarchives and instantiates the in-memory contents of the receiver’s nib file, creating a distinct object tree and set of top level objects.

static let externalObjects: UINib.OptionsKey

The replacements for any proxy objects in the nib file. The value for this key is an NSDictionary object. The keys of the dictionary are the names of any proxy objects in the nib file, and the value for each key is the actual object to use in place of the proxy.


Inherits From

Conforms To