iOS Developer Library

Developer

UIKit Framework Reference NSObject UIKit Additions Reference

Options
Deployment Target:

On This Page
Language:

NSObject

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

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


import UIKit @import UIKit;

Availability


Available in iOS 2.0 and later.
  • Prepares the receiver for service after it has been loaded from an Interface Builder archive, or nib file.

    Declaration

    Swift

    func awakeFromNib()

    Objective-C

    - (void)awakeFromNib

    Discussion

    The nib-loading infrastructure sends an awakeFromNib message to each object recreated from a nib archive, but only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established.

    You must call the super implementation of awakeFromNib to give parent classes the opportunity to perform any additional initialization they require. Although the default implementation of this method does nothing, many UIKit classes provide non-empty implementations. You may call the super implementation at any point during your own awakeFromNib method.

    During the instantiation process, each object in the archive is unarchived and then initialized with the method befitting its type. Objects that conform to the NSCoding protocol (including all subclasses of UIView and UIViewController) are initialized using their initWithCoder: method. All objects that do not conform to the NSCoding protocol are initialized using their init method. After all objects have been instantiated and initialized, the nib-loading code reestablishes the outlet and action connections for all of those objects. It then calls the awakeFromNib method of the objects. For more detailed information about the steps followed during the nib-loading process, see Nib Files in Resource Programming Guide.

    Typically, you implement awakeFromNib for objects that require additional set up that cannot be done at design time. For example, you might use this method to customize the default configuration of any controls to match user preferences or the values in other controls. You might also use it to restore individual controls to some previous state of your application.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    awakeAfterUsingCoder: (NSObject class)
    initWithCoder: (NSCoding protocol)
    initialize (NSObject class)

  • Asks the object to increase the size of an item.

    Declaration

    Swift

    func increaseSize(_ sender: AnyObject?)

    Objective-C

    - (void)increaseSize:(id)sender

    Discussion

    The system calls this action method in response to the user pressing Command-plus (+) on an attached hardware keyboard. Typical responses for this type of event are to increase the font size of text or to change the zoom level of scroll views.

    Import Statement

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Asks the object to decrease the size of an item.

    Declaration

    Swift

    func decreaseSize(_ sender: AnyObject?)

    Objective-C

    - (void)decreaseSize:(id)sender

    Discussion

    The system calls this action method in response to the user pressing Command-minus (-) on an attached hardware keyboard. Typical responses for this type of event are to decrease the font size of text or to change the zoom level of scroll views.

    Import Statement

    import UIKit

    Availability

    Available in iOS 7.0 and later.