Class

NSObject

The root class of most Objective-C class hierarchies, from which subclasses inherit a basic interface to the runtime system and the ability to behave as Objective-C objects.

Declaration

@interface NSObject

Topics

Initializing a Class

+ initialize

Initializes the class before it receives its first message.

+ load

Invoked whenever a class or category is added to the Objective-C runtime; implement this method to perform class-specific behavior upon loading.

Creating, Copying, and Deallocating Objects

+ alloc

Returns a new instance of the receiving class.

+ allocWithZone:

Returns a new instance of the receiving class.

- init

Implemented by subclasses to initialize a new object (the receiver) immediately after memory for it has been allocated.

- copy

Returns the object returned by copyWithZone:.

+ copyWithZone:

Returns the receiver.

- mutableCopy

Returns the object returned by mutableCopyWithZone: where the zone is nil.

+ mutableCopyWithZone:

Returns the receiver.

- dealloc

Deallocates the memory occupied by the receiver.

+ new

Allocates a new instance of the receiving class, sends it an init message, and returns the initialized object.

Identifying Classes

+ class

Returns the class object.

+ superclass

Returns the class object for the receiver’s superclass.

+ isSubclassOfClass:

Returns a Boolean value that indicates whether the receiving class is a subclass of, or identical to, a given class.

Testing Class Functionality

+ instancesRespondToSelector:

Returns a Boolean value that indicates whether instances of the receiver are capable of responding to a given selector.

Testing Protocol Conformance

+ conformsToProtocol:

Returns a Boolean value that indicates whether the receiver conforms to a given protocol.

Obtaining Information About Methods

- methodForSelector:

Locates and returns the address of the receiver’s implementation of a method so it can be called as a function.

+ instanceMethodForSelector:

Locates and returns the address of the implementation of the instance method identified by a given selector.

+ instanceMethodSignatureForSelector:

Returns an NSMethodSignature object that contains a description of the instance method identified by a given selector.

- methodSignatureForSelector:

Returns an NSMethodSignature object that contains a description of the method identified by a given selector.

Describing Objects

+ description

Returns a string that represents the contents of the receiving class.

Supporting Discardable Content

autoContentAccessingProxy

A proxy for the receiving object

Sending Messages

- performSelector:withObject:afterDelay:

Invokes a method of the receiver on the current thread using the default mode after a delay.

- performSelector:withObject:afterDelay:inModes:

Invokes a method of the receiver on the current thread using the specified modes after a delay.

- performSelectorOnMainThread:withObject:waitUntilDone:

Invokes a method of the receiver on the main thread using the default mode.

- performSelectorOnMainThread:withObject:waitUntilDone:modes:

Invokes a method of the receiver on the main thread using the specified modes.

- performSelector:onThread:withObject:waitUntilDone:

Invokes a method of the receiver on the specified thread using the default mode.

- performSelector:onThread:withObject:waitUntilDone:modes:

Invokes a method of the receiver on the specified thread using the specified modes.

- performSelectorInBackground:withObject:

Invokes a method of the receiver on a new background thread.

+ cancelPreviousPerformRequestsWithTarget:

Cancels perform requests previously registered with the performSelector:withObject:afterDelay: instance method.

Forwarding Messages

- forwardingTargetForSelector:

Returns the object to which unrecognized messages should first be directed.

- forwardInvocation:

Overridden by subclasses to forward messages to other objects.

Dynamically Resolving Methods

+ resolveClassMethod:

Dynamically provides an implementation for a given selector for a class method.

+ resolveInstanceMethod:

Dynamically provides an implementation for a given selector for an instance method.

Handling Errors

- doesNotRecognizeSelector:

Handles messages the receiver doesn’t recognize.

Archiving

- awakeAfterUsingCoder:

Overridden by subclasses to substitute another object in place of the object that was decoded and subsequently received this message.

classForArchiver

The class to substitute for the receiver's own class during archiving.

classForCoder

Overridden by subclasses to substitute a class other than its own during coding.

classForKeyedArchiver

Subclasses to substitute a new class for instances during keyed archiving.

+ classFallbacksForKeyedArchiver

Overridden to return the names of classes that can be used to decode objects if their class is unavailable.

+ classForKeyedUnarchiver

Overridden by subclasses to substitute a new class during keyed unarchiving.

classForPortCoder

Class to substitute for the receiver in distribution encoding.

Deprecated
- replacementObjectForArchiver:

Overridden by subclasses to substitute another object for itself during archiving.

Deprecated
- replacementObjectForCoder:

Overridden by subclasses to substitute another object for itself during encoding.

- replacementObjectForKeyedArchiver:

Overridden by subclasses to substitute another object for itself during keyed archiving.

+ setVersion:

Sets the receiver's version number.

+ version

Returns the version number assigned to the class.

Working with Class Descriptions

attributeKeys

An array of NSString objects containing the names of immutable values that instances of the receiver's class contain.

classDescription

An object containing information about the attributes and relationships of the receiver’s class.

- inverseForRelationshipKey:

For a given key that defines the name of the relationship from the receiver’s class to another class, returns the name of the relationship from the other class to the receiver’s class.

toManyRelationshipKeys

An array containing the keys for the to-many relationship properties of the receiver.

toOneRelationshipKeys

The keys for the to-one relationship properties of the receiver, if any.

Improving Accessibility

UIAccessibility

A set of methods that provide accessibility information about views and controls in an app's user interface.

UIAccessibilityContainer

Provide a set of methods that view subclasses use to make subcomponents accessible as separate elements.

UIAccessibilityAction

A set of methods that accessibility elements can use to support specific actions.

UIAccessibilityFocus

An informal protocol that provides a way to find out whether an assistive technology, such as VoiceOver, is focused on an accessible element.

UIAccessibilityDragging

A pair of properties to allow you to fine-tune how drags and drops are exposed to assistive technologies.

Scripting

classCode

The receiver's Apple event type code, as stored in the NSScriptClassDescription object for the object’s class.

className

A string containing the name of the class.

- copyScriptingValue:forKey:withProperties:

Creates and returns one or more scripting objects to be inserted into the specified relationship by copying the passed-in value and setting the properties in the copied object or objects.

- newScriptingObjectOfClass:forValueForKey:withContentsValue:properties:

Creates and returns an instance of a scriptable class, setting its contents and properties, for insertion into the relationship identified by the key.

scriptingProperties

An NSString-keyed dictionary of the receiver's scriptable properties.

- scriptingValueForSpecifier:

Given an object specifier, returns the specified object or objects in the receiving container.

Key-Value Observing

NSKeyValueObserving

An informal protocol that objects adopt to be notified of changes to the specified properties of other objects.

Key-Value Coding

NSKeyValueBindingCreation

A set of methods that you can use to create and remove bindings between view objects and controllers, or between controllers and model objects.

NSKeyValueCoding

A mechanism by which you can access the properties of an object indirectly by name or key.

NSScriptKeyValueCoding

A collection of methods that provide additional capabilities for working with key-value coding.

NSScriptKeyValueCoding Exception Names

Exceptions raised by key-value coding methods.

Interacting with Web Plug-ins

WebPlugInContainer

WebPlugInContainer is an informal protocol that enables a plug-in to send messages to the application.

WebPlugIn

The WebPlugIn informal protocol defines methods that enable interaction between an application using the WebKit framework and any WebKit-based plug-ins it may use.

Implementing Web Scripting

WebScripting

WebScripting is an informal protocol that defines methods that classes can implement to export their interfaces to a WebScript environment such as JavaScript.

Supporting Cocoa Scripting

NSScriptingComparisonMethods

A collection of methods useful for comparing script objects.

Deprecated

Avoid using deprecated classes and protocols in your apps.

Deprecated Symbols

Review symbols that are no longer supported and find the replacements to use instead.

Instance Properties

objectSpecifier

Returns an object specifier for the receiver.

Instance Methods

- actionProperty

Sent to the delegate to request the property the action applies to.

- attemptRecoveryFromError:optionIndex:

Implemented to attempt a recovery from an error noted in an application-modal dialog.

- attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:

Implemented to attempt a recovery from an error noted in a document-modal sheet.

- authorizationViewCreatedAuthorization:

Sent to the delegate to indicate the authorization object has been created or changed. If you have saved a copy of the authorization object for your own purposes, you should discard it and call authorization for a new authorization object.

- authorizationViewDidAuthorize:

Sent to the delegate to indicate the user was authorized and the authorization view was changed to unlocked.

- authorizationViewDidDeauthorize:

Sent to the delegate to indicate the user was deauthorized and the authorization view was changed to locked.

- authorizationViewDidHide:

Sent to the delegate to indicate that the view’s visibility has changed.

- authorizationViewReleasedAuthorization:

Sent to the delegate to indicate that deauthorization is about to occur.

- authorizationViewShouldDeauthorize:

Sent to the delegate when a user clicks the open lock icon.

- awakeFromNib

Prepares the receiver for service after it has been loaded from an Interface Builder archive, or nib file.

- candidates:

Returns an array of candidates.

- certificatePanelShowHelp:

Implements custom help behavior for the modal panel.

- chooseIdentityPanelShowHelp:

Implements custom help behavior for the modal panel.

- commitComposition:

Informs the controller that the composition should be committed.

- composedString:

Return the current composed string.

- compositionParameterView:didChangeParameterWithKey:

Called after an input parameter in the composition parameter view has been edited.

- compositionParameterView:shouldDisplayParameterWithKey:attributes:

Allows you to define which composition parameters are visible in the user interface when the composition parameter view refreshes.

- compositionPickerView:didSelectComposition:

Performs custom tasks when the selected composition in the composition picker view changes.

- compositionPickerViewDidStartAnimating:

Performs custom tasks when the composition picker view starts animating a composition.

- compositionPickerViewWillStopAnimating:

Performs custom tasks when the composition picker view stops animating a composition.

- didCommandBySelector:client:

Processes a command generated by user action such as typing certain keys or pressing the mouse button.

- doesContain:

Returns a Boolean value that indicates whether the receiver contains a given object.

- exceptionHandler:shouldHandleException:mask:

Implemented by the delegate to evaluate whether the delegating NSExceptionHandler instance should handle a given exception.

- exceptionHandler:shouldLogException:mask:

Implemented by the delegate to evaluate whether the delegating NSExceptionHandler instance should log a given exception.

- handleEvent:client:

Handles key down and mouse events.

- imageBrowser:backgroundWasRightClickedWithEvent:

Performs custom tasks when the user right-clicks the image browser view background.

- imageBrowser:cellWasDoubleClickedAtIndex:

Performs custom tasks when the user double-clicks an item in the image browser view.

- imageBrowser:cellWasRightClickedAtIndex:withEvent:

Performs custom tasks when the user right-clicks an item in the image browser view.

- imageBrowser:groupAtIndex:

Returns the group at the specified index.

- imageBrowser:itemAtIndex:

Returns an object for the item in an image browser view that corresponds to the specified index.

- imageBrowser:moveItemsAtIndexes:toIndex:

Signals that the specified items should be moved to the specified destination.

- imageBrowser:removeItemsAtIndexes:

Signals that a remove operation should be applied to the specified items.

- imageBrowser:writeItemsAtIndexes:toPasteboard:

Signals that a drag should begin.

- imageBrowserSelectionDidChange:

Performs custom tasks when the selection changes.

- imageRepresentation

Returns the image to display.

- imageRepresentationType

Returns the representation type of the image to display.

- imageSubtitle

Returns the display subtitle of the image.

- imageTitle

Returns the display title of the image.

- imageUID

Returns a unique string that identifies the data source item.

- imageVersion

Returns the version of the item.

- indicesOfObjectsByEvaluatingObjectSpecifier:

Returns the indices of the specified container objects.

- inputText:client:

Handles key down events that do not map to an action method.

- inputText:key:modifiers:client:

Receives Unicode, the key code that generated it, and any modifier flags.

- isCaseInsensitiveLike:

Returns a Boolean value that indicates whether receiver is considered to be “like” a given string when the case of characters in the receiver is ignored.

- isEqualTo:

Returns a Boolean value that indicates whether the receiver is equal to another given object.

- isGreaterThan:

Returns a Boolean value that indicates whether the receiver is greater than another given object.

- isGreaterThanOrEqualTo:

Returns a Boolean value that indicates whether the receiver is greater than or equal to another given object.

- isLessThan:

Returns a Boolean value that indicates whether the receiver is less than another given object.

- isLessThanOrEqualTo:

Returns a Boolean value that indicates whether the receiver is less than or equal to another given object.

- isLike:

Returns a Boolean value that indicates whether the receiver is "like" another given object.

- isNotEqualTo:

Returns a Boolean value that indicates whether the receiver is not equal to another given object.

- numberOfGroupsInImageBrowser:

Returns the number of groups in an image browser view.

- numberOfItemsInImageBrowser:

Returns the number of records managed by the data source object.

- originalString:

Return the string that consists of the precomposed Unicode characters.

- performActionForPerson:identifier:

Sent to the delegate to perform the action.

- prepareForInterfaceBuilder

Called when a designable object is created in Interface Builder.

- saveOptions:shouldShowUTType:

Called to determine if the specified uniform type identifier should be shown in the save panel.

- shouldEnableActionForPerson:identifier:

Sent to the delegate to determine whether the action should be enabled.

- titleForPerson:identifier:

Sent to the delegate to request the title of the menu item for the action.

- PDEPanelsForType:withHostInfo:

Returns an array of panes to be added to a printing dialog.

- PMPrinter

Returns the current printer object.

- PPDOptionKeyValueDidChange:ppdChoice:

Handles a change in the value of a PPD option that the pane supports.

- application:delegateHandlesKey:

Sent by Cocoa’s built-in scripting support during execution of get or set script commands to find out if the delegate can handle operations on the specified key-value key.

Deprecated
- changeColor:

Sent to the first responder when the user selects a color in an NSColorPanel object.

Deprecated
- changeFont:

Informs responders of a font change.

Deprecated
- commitEditing

Returns whether the receiver was able to commit any pending edits.

Deprecated
- commitEditingAndReturnError:

Attempt to commit pending edits, returning an error in the case of failure.

Deprecated
- commitEditingWithDelegate:didCommitSelector:contextInfo:

Attempt to commit any currently edited results of the receiver.

Deprecated
- controlTextDidBeginEditing:

Sent when a control with editable text begins an editing session.

Deprecated
- controlTextDidChange:

Sent when the text in the receiving control changes.

Deprecated
- controlTextDidEndEditing:

Sent when a control with editable text ends an editing session.

Deprecated
- discardEditing

Causes the receiver to discard any changes, restoring the previous values.

Deprecated
- initWithBundle:

Initializes the plug-in.

- layer:shouldInheritContentsScale:fromWindow:

Invoked when a resolution changes occurs for the window that hosts the layer.

Deprecated
- objectDidBeginEditing:

This message should be sent to the receiver when editor has uncommitted changes that can affect the receiver.

Deprecated
- objectDidEndEditing:

This message should be sent to the receiver when editor has finished editing a property belonging to the receiver.

Deprecated
- pageFormat

Returns the current page format object.

- panel:compareFilename:with:caseSensitive:

Controls the ordering of files presented by the NSSavePanel object specified.

Deprecated
- panel:directoryDidChange:

Tells the delegate that the user has changed the selected directory in the NSSavePanel object specified.

Deprecated
- panel:isValidFilename:

Gives the delegate the opportunity to validate selected items.

Deprecated
- panel:shouldShowFilename:

Gives the delegate the opportunity to filter items that it doesn’t want the user to choose.

Deprecated
- panelKind

Returns the kind ID of the pane.

- panelName

Returns the localized name of the pane.

- panelView

Returns a view that contains the pane’s user interface.

- pasteboard:provideDataForType:

Implemented by an owner object to provide promised data.

Deprecated
- pasteboardChangedOwner:

Notifies a prior owner of the specified pasteboard (and owners of representations on the pasteboard) that the pasteboard has changed owners.

Deprecated
- ppdFile

Returns a CUPS object used to access information about the current printer.

- printSession

Returns the current print session object.

- printSettings

Returns the current print settings object.

- restoreValuesAndReturnError:

Restores the pane’s settings.

- saveValuesAndReturnError:

Verifies that the pane’s settings are valid and have been saved.

- shouldHide

Prepares the pane to be hidden.

- summaryInfo

Returns localized text descriptions of the pane’s current settings.

- supportedPPDOptionKeys

Declares that the pane supports one or more PPD options.

- tableView:writeRows:toPasteboard:

Writes the specified rows to the specified pasteboard.

Deprecated
- validModesForFontPanel:

Returns the mode mask corresponding to the expected font panel mode.

Deprecated
- validateMenuItem:

Implemented to override the default action of enabling or disabling a specific menu item.

Deprecated
- validateToolbarItem:

If this method is implemented and returns NO, NSToolbar will disable theItem; returning YES causes theItem to be enabled.

Deprecated
- view:stringForToolTip:point:userData:

Returns the tool tip string to be displayed due to the cursor pausing at location point within the tool tip rectangle identified by tag in the view view.

Deprecated
- willChangePPDOptionKeyValue:ppdChoice:

Requests a change in the value of a PPD option.

- willShow

Prepares the pane for display.

Relationships

Conforms To

See Also

Object Basics

NSObject

The group of methods that are fundamental to all Objective-C objects.

NSKeyValueCoding

A mechanism by which you can access the properties of an object indirectly by name or key.