Instance Method

copy

Returns the object returned by copyWithZone:.

Declaration

- (id)copy;

Return Value

The object returned by the NSCopying protocol method copyWithZone:,.

Discussion

This is a convenience method for classes that adopt the NSCopying protocol. An exception is raised if there is no implementation for copyWithZone:.

NSObject does not itself support the NSCopying protocol. Subclasses must support the protocol and implement the copyWithZone: method. A subclass version of the copyWithZone: method should send the message to super first, to incorporate its implementation, unless the subclass descends directly from NSObject.

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.

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