Instance Method

instantiateWithOwner:options:

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

Declaration

- (NSArray *)instantiateWithOwner:(id)ownerOrNil options:(NSDictionary<UINibOptionsKey, id> *)optionsOrNil;

Parameters

ownerOrNil

The object to use as the owner of the nib file. If the nib file has an owner, you must specify a valid object for this parameter.

optionsOrNil

A dictionary containing the options to use when opening the nib file. For a list of available keys for this dictionary, see NSBundle UIKit Additions.

Return Value

An autoreleased NSArray object containing the top-level objects from the nib file.

Discussion

You can use this method to instantiate the objects in a nib and provide them to your code. This method unarchives each object, initializes it, sets its properties to their configured values, and reestablishes any connections to other objects. For detailed information about the nib-loading process, see Resource Programming Guide.

If the nib file contains any proxy objects beyond just the File’s Owner proxy object, you can specify the runtime replacement objects for those proxies using the options dictionary. In that dictionary, add the UINibExternalObjects key and set its value to a dictionary containing the names of any proxy objects (the keys) and the real objects to use in their place. The proxy object’s name is the string you assign to it in the Name field of the Interface Builder inspector window.

See Also

Retrieving Objects from the Nib File

UINibProxiedObjectsKey

In iOS 2.x, the value for this key is a dictionary that contains the runtime replacement objects for any proxy objects used in the nib file. In this dictionary, the keys are the names associated with the proxy objects and the values are the actual objects from your code that should be used in their place.

Deprecated
UINibExternalObjects

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.