Deep copy and shallow copy of IOS

Source: Internet
Author: User

Note that this article only says the conclusion does not say the process

1. For non-container class objects of the system, we can assume that if copying an immutable object, copy is pointer copy (shallow copy) and mutablecopy is the object copy (deep copy). If it is a copy of a mutable object, it is a deep copy, but the object returned by copy is immutable.

2. The System container class object, refers to Nsarray,nsdictionary and so on. For the container class itself, the conclusion of the first discussion is also applicable, and it is necessary to explore the changes of the objects in the container after replication. The conclusion of the deep copy can be viewed in the official Apple document; address https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Collections/ Articles/copying.html

3. If it is our custom object, then we must abide by the nscopying,nsmutablecopying, and implement Copywithzone:,mutablecopywithzone: Method, So you can call copy and mutablecopy.

Deep copy and shallow copy of IOS

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.