iOS Developer Library

Developer

UIKit Framework Reference NSBundle UIKit Additions Reference

Options
Deployment Target:

On This Page
Language:

NSBundle

Inherits From


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 2.0 and later

This category adds methods to the Foundation framework’s NSBundle class. The method in this category provides support for loading nib files into your application.

  • Unarchives the contents of a nib file located in the receiver's bundle.

    Declaration

    Swift

    func loadNibNamed(_ name: String!, owner owner: AnyObject!, options options: [NSObject : AnyObject]!) -> [AnyObject]!

    Objective-C

    - (NSArray *)loadNibNamed:(NSString *)name owner:(id)owner options:(NSDictionary *)options

    Parameters

    name

    The name of the nib file, which need not include the .nib extension.

    owner

    The object to assign as the nib’s File's Owner object.

    options

    A dictionary containing the options to use when opening the nib file. For a list of available keys for this dictionary, see Nib File Loading Options.

    Return Value

    An array containing the top-level objects in the nib file. The array does not contain references to the File’s Owner or any proxy objects; it contains only those objects that were instantiated when the nib file was unarchived. You should retain either the returned array or the objects it contains manually to prevent the nib file objects from being released prematurely.

    Discussion

    You can use this method to load user interfaces and make the objects available to your code. During the loading process, this method unarchives each object, initializes it, sets its properties to their configured values, and reestablishes any connections to other objects. (To establish outlet connections, this method uses the setValue:forKey: method, which may cause the object in the outlet to be retained automatically.) 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 Identifier field of the Interface Builder inspector window.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later

  • The options that can be specified during nib loading.

    Declaration

    Swift

    let UINibExternalObjects: String

    Objective-C

    extern NSString * const UINibProxiedObjectsKey; extern NSString * const UINibExternalObjects

    Constants

    • UINibProxiedObjectsKey

      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.

      Use the UINibExternalObjects key instead.

      Available in iOS 2.0 and later

      Deprecated in iOS 3.0

    • UINibExternalObjects

      UINibExternalObjects

      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.

      Available in iOS 3.0 and later