Instance Method

copy()

Returns the object returned by copy(with:).

Declaration

func copy() -> Any

Return Value

The object returned by the NSCopying protocol method copy(with:),.

Discussion

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

NSObject does not itself support the NSCopying protocol. Subclasses must support the protocol and implement the copy(with:) method. A subclass version of the copy(with:) 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

init()

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

func mutableCopy() -> Any

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

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