[Reading Notes] iOS-copying types, Reading Notes ios-copying

Source: Internet
Author: User

[Reading Notes] iOS-copying types, Reading Notes ios-copying

1. You can use different methods to copy objects. Most Objects Reference (that is, point to) other objects.

2. Copy objects in the shallow layer without copying referenced objects. The newly copied objects only point to existing referenced objects. The copy method of the NSArray class is shallow copy. When copying an NSArray object, the object you copy only copies the pointer to the referenced object, instead of the referenced object itself. If you copy an NSArray object that contains five NSString objects, you finally get five string objects available for the program, instead of ten string objects. In that case, each new object eventually obtains a pointer to a string object.

3. Deep replication copies all referenced objects. If NSArray's copy method is deep copy, you will get 10 available string objects after the copy operation is complete.

4. You can freely mix and match deep replication and shallow replication based on the needs of specific classes.


References: Objective-C Basics

Related Article

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.