Instance Method


Deallocates the memory occupied by the receiver.


- (void)dealloc;


Subsequent messages to the receiver may generate an error indicating that a message was sent to a deallocated object (provided the deallocated memory hasn’t been reused yet).

You override this method to dispose of resources other than the object’s instance variables, for example:

- (void)dealloc {

In an implementation of dealloc, do not invoke the superclass’s implementation. You should try to avoid managing the lifetime of limited resources such as file descriptors using dealloc.

You never send a dealloc message directly. Instead, an object’s dealloc method is invoked by the runtime. See Advanced Memory Management Programming Guide for more details.

Special Considerations

When not using ARC, your implementation of dealloc must invoke the superclass’s implementation as its last instruction.

See Also

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.

+ new

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software