attribute variables and member variables in OBJETIVE-C

Source: Internet
Author: User


Property Variables @property and @synthesize can automatically generate access methods for a class member variable.

ReadWrite: This property is the default and will automatically generate accessors

Assign: This property is generally used to deal with the underlying types, such as int, float, and so on.

Copy: Specifies that a copy of the object (deep copy) should be used, and the previous value sends a release message.

Basically like retain, but without increasing the reference count, it is allocating a new piece of memory to place it.

Copy is to create a new object, retain is to create a pointer to reference the object Count plus 1. Copy

Create an object with an index count of 1. Then release the old object, copy is to create a new object,

Retain is to create a pointer that references an object plus 1.

ReadOnly: Only getter methods will be generated, not setter methods.

ReadWrite: Default property that will generate getter and setter methods with no extra parameters (setter has only one parameter)

Atomic: The default property for an object is that the Setter/getter generated method is an atomic operation. If multiple

When a thread calls the setter at the same time, one thread does not appear before the entire setter statement is executed, and the other

When a thread starts executing a setter, it is the same as the method ends with a lock.

Nonatomic: The atomicity of Setter/getter is not guaranteed, and data may be problematic in multithreaded situations.

nonatomic, non-atomic access, non-synchronous, multi-threaded concurrent access improves performance. First release the original

variable, and then the new variable retain then assigns the value;

  A member variable is a private variable of the class that is visible only to that class.

attribute variables and member variables in OBJETIVE-C

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: 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.