<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject"
  },
  "title" : "NSObject"
}
-->

# 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.

```
class NSObject
```

## Topics

### Initializing a Class

[`+  initialize`](/documentation/ObjectiveC/NSObject-swift.class/initialize())

Initializes the class before it receives its first message.

[`+  load`](/documentation/ObjectiveC/NSObject-swift.class/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`](/documentation/ObjectiveC/NSObject-swift.class/alloc)

Returns a new instance of the receiving class.

[`+  allocWithZone:`](/documentation/ObjectiveC/NSObject-swift.class/allocWithZone:)

Returns a new instance of the receiving class.

[`-  init`](/documentation/ObjectiveC/NSObject-swift.class/init())

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

[`-  copy`](/documentation/ObjectiveC/NSObject-swift.class/copy())

Returns the object returned by `copy(with:)`.

[`+  copyWithZone:`](/documentation/ObjectiveC/NSObject-swift.class/copyWithZone:)

Returns the receiver.

[`-  mutableCopy`](/documentation/ObjectiveC/NSObject-swift.class/mutableCopy())

Returns the object returned by `mutableCopy(with:)` where the zone is `nil`.

[`+  mutableCopyWithZone:`](/documentation/ObjectiveC/NSObject-swift.class/mutableCopyWithZone:)

Returns the receiver.

[`-  dealloc`](/documentation/ObjectiveC/NSObject-swift.class/dealloc)

Deallocates the memory occupied by the receiver.

[`+  new`](/documentation/ObjectiveC/NSObject-swift.class/new)

Allocates a new instance of the receiving class, sends it an [`init()`](/documentation/ObjectiveC/NSObject-swift.class/init()) message, and returns the initialized object.

### Identifying Classes

[`+  class`](/documentation/ObjectiveC/NSObject-swift.class/class)

Returns the class object.

[`+  superclass`](/documentation/ObjectiveC/NSObject-swift.class/superclass())

Returns the class object for the receiver’s superclass.

[`+  isSubclassOfClass:`](/documentation/ObjectiveC/NSObject-swift.class/isSubclass(of:))

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

### Testing Class Functionality

[`+  instancesRespondToSelector:`](/documentation/ObjectiveC/NSObject-swift.class/instancesRespond(to:))

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

### Testing Protocol Conformance

[`+  conformsToProtocol:`](/documentation/ObjectiveC/NSObject-swift.class/conforms(to:))

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

### Obtaining Information About Methods

[`-  methodForSelector:`](/documentation/ObjectiveC/NSObject-swift.class/method(for:))

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

[`+  instanceMethodForSelector:`](/documentation/ObjectiveC/NSObject-swift.class/instanceMethod(for:))

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

[`+  instanceMethodSignatureForSelector:`](/documentation/ObjectiveC/NSObject-swift.class/instanceMethodSignatureForSelector:)

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

[`-  methodSignatureForSelector:`](/documentation/ObjectiveC/NSObject-swift.class/methodSignatureForSelector:)

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

### Describing Objects

[`+  description`](/documentation/ObjectiveC/NSObject-swift.class/description())

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

### Supporting Discardable Content

[`autoContentAccessingProxy`](/documentation/ObjectiveC/NSObject-swift.class/autoContentAccessingProxy)

A proxy for the receiving object

### Sending Messages

[`-  performSelector:withObject:afterDelay:`](/documentation/ObjectiveC/NSObject-swift.class/perform(_:with:afterDelay:))

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

[`-  performSelector:withObject:afterDelay:inModes:`](/documentation/ObjectiveC/NSObject-swift.class/perform(_:with:afterDelay:inModes:))

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

[`-  performSelectorOnMainThread:withObject:waitUntilDone:`](/documentation/ObjectiveC/NSObject-swift.class/performSelector(onMainThread:with:waitUntilDone:))

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

[`-  performSelectorOnMainThread:withObject:waitUntilDone:modes:`](/documentation/ObjectiveC/NSObject-swift.class/performSelector(onMainThread:with:waitUntilDone:modes:))

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

[`-  performSelector:onThread:withObject:waitUntilDone:`](/documentation/ObjectiveC/NSObject-swift.class/perform(_:on:with:waitUntilDone:))

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

[`-  performSelector:onThread:withObject:waitUntilDone:modes:`](/documentation/ObjectiveC/NSObject-swift.class/perform(_:on:with:waitUntilDone:modes:))

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

[`-  performSelectorInBackground:withObject:`](/documentation/ObjectiveC/NSObject-swift.class/performSelector(inBackground:with:))

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

[`+  cancelPreviousPerformRequestsWithTarget:`](/documentation/ObjectiveC/NSObject-swift.class/cancelPreviousPerformRequests(withTarget:))

Cancels perform requests previously registered with the [`perform(_:with:afterDelay:)`](/documentation/ObjectiveC/NSObject-swift.class/perform(_:with:afterDelay:)) instance method.

[`+  cancelPreviousPerformRequestsWithTarget:selector:object:`](/documentation/ObjectiveC/NSObject-swift.class/cancelPreviousPerformRequests(withTarget:selector:object:))

Cancels perform requests previously registered with [`perform(_:with:afterDelay:)`](/documentation/ObjectiveC/NSObject-swift.class/perform(_:with:afterDelay:)).

### Forwarding Messages

[`-  forwardingTargetForSelector:`](/documentation/ObjectiveC/NSObject-swift.class/forwardingTarget(for:))

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

[`-  forwardInvocation:`](/documentation/ObjectiveC/NSObject-swift.class/forwardInvocation:)

Overridden by subclasses to forward messages to other objects.

### Dynamically Resolving Methods

[`+  resolveClassMethod:`](/documentation/ObjectiveC/NSObject-swift.class/resolveClassMethod(_:))

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

[`+  resolveInstanceMethod:`](/documentation/ObjectiveC/NSObject-swift.class/resolveInstanceMethod(_:))

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

### Handling Errors

[`-  doesNotRecognizeSelector:`](/documentation/ObjectiveC/NSObject-swift.class/doesNotRecognizeSelector(_:))

Handles messages the receiver doesn’t recognize.

### Archiving

[`-  awakeAfterUsingCoder:`](/documentation/ObjectiveC/NSObject-swift.class/awakeAfter(using:))

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

[`classForArchiver`](/documentation/ObjectiveC/NSObject-swift.class/classForArchiver)

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

[`classForCoder`](/documentation/ObjectiveC/NSObject-swift.class/classForCoder)

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

[`classForKeyedArchiver`](/documentation/ObjectiveC/NSObject-swift.class/classForKeyedArchiver)

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

[`+  classFallbacksForKeyedArchiver`](/documentation/ObjectiveC/NSObject-swift.class/classFallbacksForKeyedArchiver())

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

[`+  classForKeyedUnarchiver`](/documentation/ObjectiveC/NSObject-swift.class/classForKeyedUnarchiver())

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

[`classForPortCoder`](/documentation/ObjectiveC/NSObject-swift.class/classForPortCoder)

Class to substitute for the receiver in distribution encoding.

[`-  replacementObjectForArchiver:`](/documentation/ObjectiveC/NSObject-swift.class/replacementObject(for:)-8ih2x)

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

[`-  replacementObjectForCoder:`](/documentation/ObjectiveC/NSObject-swift.class/replacementObject(for:)-2l8ox)

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

[`-  replacementObjectForKeyedArchiver:`](/documentation/ObjectiveC/NSObject-swift.class/replacementObject(for:)-60vwc)

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

[`+  setVersion:`](/documentation/ObjectiveC/NSObject-swift.class/setVersion(_:))

Sets the receiver’s version number.

[`+  version`](/documentation/ObjectiveC/NSObject-swift.class/version())

Returns the version number assigned to the class.

### Working with Class Descriptions

[`attributeKeys`](/documentation/ObjectiveC/NSObject-swift.class/attributeKeys)

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

[`classDescription`](/documentation/ObjectiveC/NSObject-swift.class/classDescription)

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

[`-  inverseForRelationshipKey:`](/documentation/ObjectiveC/NSObject-swift.class/inverse(forRelationshipKey:))

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`](/documentation/ObjectiveC/NSObject-swift.class/toManyRelationshipKeys)

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

[`toOneRelationshipKeys`](/documentation/ObjectiveC/NSObject-swift.class/toOneRelationshipKeys)

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

### Improving Accessibility

  <doc://com.apple.documentation/documentation/UIKit/uiaccessibility-protocol>

  <doc://com.apple.documentation/documentation/UIKit/uiaccessibilitycontainer>

[UIAccessibilityAction](/documentation/ObjectiveC/uiaccessibilityaction)

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

[UIAccessibilityFocus](/documentation/ObjectiveC/uiaccessibilityfocus)

An informal protocol that provides a way to determine whether an assistive app, such as VoiceOver, has focus on an accessible element.

[UIAccessibilityDragging](/documentation/ObjectiveC/uiaccessibilitydragging)

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

### Improving browser accessibility

[`-  browserAccessibilityAttributedValueInRange:`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityAttributedValue(in:))

Returns the value for this element within the given range, as an attributed string.

[`-  browserAccessibilityDeleteTextAtCursor:`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityDeleteTextAtCursor(numberOfCharacters:))

Deletes text from the element at the current cursor position.

[`-  browserAccessibilityInsertTextAtCursor:`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityInsertTextAtCursor(text:))

Inserts text into the element at the current cursor position.

[`-  browserAccessibilitySelectedTextRange`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilitySelectedTextRange())

Returns the range of selected text in the element.

[`-  browserAccessibilitySetSelectedTextRange:`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilitySetSelectedTextRange(_:))

Updates the element’s selected text.

[`-  browserAccessibilityValueInRange:`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityValue(in:))

Returns this element’s value in the given range.

[`browserAccessibilityContainerType`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityContainerType)

The kind of container that contains this element.

[`browserAccessibilityCurrentStatus`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityCurrentStatus)

A string that’s the element’s value for aria-current.

[`browserAccessibilityHasDOMFocus`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityHasDOMFocus)

A Boolean value that indicates whether the element has native focus in the browser Document Object Model.

[`browserAccessibilityIsRequired`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityIsRequired)

A Boolean value that’s the element’s value for aria-required.

[`browserAccessibilityPressedState`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityPressedState)

The element’s value for aria-pressed.

[`browserAccessibilityRoleDescription`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilityRoleDescription)

A string that describes the element’s role for assistive technologies.

[`browserAccessibilitySortDirection`](/documentation/ObjectiveC/NSObject-swift.class/browserAccessibilitySortDirection)

A string that’s the element’s value for aria-sort.

### Scripting

[`classCode`](/documentation/ObjectiveC/NSObject-swift.class/classCode)

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

[`className`](/documentation/ObjectiveC/NSObject-swift.class/className)

A string containing the name of the class.

[`-  copyScriptingValue:forKey:withProperties:`](/documentation/ObjectiveC/NSObject-swift.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:`](/documentation/ObjectiveC/NSObject-swift.class/newScriptingObject(of: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`](/documentation/ObjectiveC/NSObject-swift.class/scriptingProperties)

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

[`-  scriptingValueForSpecifier:`](/documentation/ObjectiveC/NSObject-swift.class/scriptingValue(for:))

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

### Integrating with Combine

[`KeyValueObservingPublisher`](/documentation/ObjectiveC/NSObject-swift.class/KeyValueObservingPublisher)

A Combine publisher that produces a new element whenever the observed value changes.

### Key-Value Observing

[NSKeyValueObserving](/documentation/ObjectiveC/nskeyvalueobserving)

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

### Key-Value Coding

[NSKeyValueBindingCreation](/documentation/ObjectiveC/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](/documentation/ObjectiveC/nskeyvaluecoding)

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

[NSScriptKeyValueCoding](/documentation/ObjectiveC/nsscriptkeyvaluecoding)

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

[NSScriptKeyValueCoding Exception Names](/documentation/ObjectiveC/nsscriptkeyvaluecoding-exception-names)

Exceptions raised by key-value coding methods.

### Interacting with Web Plug-ins

[WebPlugInContainer](/documentation/ObjectiveC/webplugincontainer)

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

[WebPlugIn](/documentation/ObjectiveC/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](/documentation/ObjectiveC/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](/documentation/ObjectiveC/nsscriptingcomparisonmethods)

A collection of methods useful for comparing script objects.

### Customizing accessibility

[`accessibilityElements`](/documentation/ObjectiveC/NSObject-swift.class/accessibilityElements)

An array of features of an object that assistive technologies can access.

### Deprecated

Avoid using deprecated classes and protocols in your apps.

[Deprecated Symbols](/documentation/ObjectiveC/deprecated-symbols)

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

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Copyable`](/documentation/Swift/Copyable)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Escapable`](/documentation/Swift/Escapable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)