Protocol

NSObject

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

Declaration

@protocol NSObject

Overview

An object that conforms to this protocol can be considered a first-class object. Such an object can be asked about its:

  • Class, and the place of its class in the inheritance hierarchy.

  • Conformance to protocols.

  • Ability to respond to a particular message.

The Cocoa root class NSObject adopts this protocol, so all objects inheriting from NSObject have the features described by this protocol.

Topics

Identifying Classes

- class

Returns the class object for the receiver’s class.

Required.

superclass

Returns the class object for the receiver’s superclass.

Required.

Identifying and Comparing Objects

- isEqual:

Returns a Boolean value that indicates whether the receiver and a given object are equal.

Required.

hash

Returns an integer that can be used as a table address in a hash table structure.

Required.

- self

Returns the receiver.

Required.

Testing Object Inheritance, Behavior, and Conformance

- isKindOfClass:

Returns a Boolean value that indicates whether the receiver is an instance of given class or an instance of any class that inherits from that class.

Required.

- isMemberOfClass:

Returns a Boolean value that indicates whether the receiver is an instance of a given class.

Required.

- respondsToSelector:

Returns a Boolean value that indicates whether the receiver implements or inherits a method that can respond to a specified message.

Required.

- conformsToProtocol:

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

Required.

Describing Objects

description

Returns a string that describes the contents of the receiver.

Required.

debugDescription

Returns a string that describes the contents of the receiver for presentation in the debugger.

Sending Messages

- performSelector:

Sends a specified message to the receiver and returns the result of the message.

Required.

- performSelector:withObject:

Sends a message to the receiver with an object as the argument.

Required.

- performSelector:withObject:withObject:

Sends a message to the receiver with two objects as arguments.

Required.

Identifying Proxies

- isProxy

Returns a Boolean value that indicates whether the receiver does not descend from NSObject.

Required.

Obsolete Methods

- retain

Increments the receiver’s reference count.

Required.

- release

Decrements the receiver’s reference count.

Required.

- autorelease

Decrements the receiver’s retain count at the end of the current autorelease pool block.

Required.

- retainCount

Do not use this method.

Required.

- zone

Zones are deprecated and ignored by most classes that have it as a parameter.

Required.

Relationships

Inherited By

Conforming Types

See Also

Object Basics

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.

NSKeyValueCoding

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