iOS Basics (i)--attribute Chapter

Source: Internet
Author: User

A property is a feature of OC (OBJECTIVE-C), like a character of a person.

This is based on OC is an object-oriented language, everything is object. That would be a good idea.

@property (nonatomic, strong) UILabel *label;

It is equivalent to declaring the Label property and implementing his setting and getting methods.

@synthesize label = _label;-(UILabel *)label;-(void)setLabel:(UILabel *)label;

What are the characteristics of a property:
1, atomicity and non-atomic nature
Atomicity (atomic) adds a sync lock when reading and writing properties, so the process is complete before it is finished, otherwise, it scrolls back to its original position.
Non-atomicity (nonatomic) is the opposite of atomicity and does not have a synchronous lock.

2. Value and Assignment
Getter method: Method of taking value
Setter Method: Assignment method

3. Memory Management
Assign: Simple assignment operations, such as: Nsinteger,gcfloat,bool
Strong: A strong reference relationship, when the referenced object disappears, it disappears, the method is set, the new value is preserved, and the old value is released.
Weak: Weak reference relationship, the Set method does not retain the new value, does not release the old value, when the pointer points to the object destroyed, the pointer is nil, resulting in a null pointer.
Copy: A deep copy with a shallow copy, a shallow copy is just a copy of the value, and there is no copy pointer. The deep copy not only copies the value, but also copies the pointer, which is equivalent to actually copying a copy.

4. Read and Write properties
ReadWrite: Has read and write properties
ReadOnly: Read-only property

iOS Basics (i)--attribute Chapter

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.