iOS Learning 5-strong/weak/copy

Source: Internet
Author: User

Strong. Weak,copy's explanation

Object uses the Strong,ui control using the weak, and the string with the copy

Now use the Arc,arc criterion: If no strong pointer is pointed to the object, an object is destroyed.

1. Strong/weak

By default, the strong pointer is *person = [[Person alloc] init];

Weak pointers using _weak adornments

The object uses strong, in order to ensure that the object is also in the attribute.

If the object has a property that is of type _weak, then it is possible that the object that the attribute points to has been destroyed and is causing the problem.

Note Circular references throw a memory leak person{Job}----Job{person}

Two object circular references there must be a _weak.

-------------

iOS 5 ago

Assign=weak

Retain=strong

--------------

2. Copy replication (deep copy, shallow copy)

3. @property Copy\weak\strong\retain\assign

* Weak (assign): Proxy/ui Control

* Strong (Retain): other objects

* Copy: String

* Assign: Non-object type (base data type, Int,float,bool, enumeration, struct)

iOS Learning 5-strong/weak/copy

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.