Copy and Mutablecopy

Source: Internet
Author: User

An object can create a copy of an object using the copy and Mutablecopy methods

Copy: The nscopying protocol needs to be implemented beforehand, and the replica created is an immutable copy (such as Nsstring,nsarray,nsdictionary)

Mutablecopy: You need to implement the Nsmutablecopying protocol first, creating a mutable copy (such as Nsmutablestring,nsmutablearray,nsmutabledictionary)

Deep copy: A copy of the content, the source object and the copy point to a different two objects. The source object reference counter is unchanged, and the replica counter is set to 1

Shallow copy: pointer copy, source object and copy point to the same object. Object reference counter +1 is actually equivalent to doing a retain operation

Only immutable objects Create immutable replicas (copy) is shallow copy, others are deep copy

Copy and Mutablecopy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.