IOS-attributes,

Source: Internet
Author: User

IOS-attributes,

Assign: simple assignment.

Retain: After a value is assigned, the new retain method and the release method of the old value are called.

Copy: copy the value first, and assign the copy value to the instance variable. This modifier is only applicable to the NSCopying protocol.

Weak: indicates that the value of this attribute will be a weak reference, and there is no relation between the reference and the referenced. If the system destroys the object referenced by a property, the property value will automatically change to nil. generally, if the parent object has a reference to a sub-object, the sub-object should not hold a reference to the parent object. Instead, the parent object should be referenced using a bypass.

On the contrary, attributes of the strong reference type indicate the relationship between the referenced object and the referenced object. From the perspective of memory usage, the description is that before the referenced object is recycled, the referenced object will not be recycled.

Nonatomic specifies that the accesser method is non-thread-safe, that is, multiple threads can simultaneously access this attribute. By default, the accessors and methods are thread-safe, even in multi-threaded environments. However, even if you want to ensure normal operation in a multi-threaded environment, the accessors are not necessarily thread-safe. If the accessors method is specified as non-thread-safe, the getter method can directly return the instance variable value, which is more efficient. It is particularly recommended for iPhone applications.

 

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.