iOS face question accumulation

Source: Internet
Author: User

1. Attribute readwrite,readonly,assign,retain,weak,strong,copy,nonatomic, function of atomic, use situation and attention point

(1). ReadWrite Features: readable writable; Condition: Generate getter, setter method; "Note": If no member variable is created directly;

(2). ReadOnly Features: Read-only, does not generate setter methods; conditions: Do not allow attributes to change outside the class; "Note": Only getter methods are generated;

(3). Assign property: Assignment, setter method assigns the passed parameter to the instance variable; case: just set the variable; "Note": After the Assign-modified (pointer) object is released in MRC mode, the pointer still points to the original place. In Arc mode, when the function is similar to the weak object, the pointer is automatically set to nil;

(4). Retain characteristics: Hold, setter method will pass in the parameters of the first reservation, and then assign value; case: Retaincount of incoming parameters +1; "Note": In principle, assign and retain are not available in Arc mode, But the compiler relaxes the requirements (it doesn't matter if it's written), and the property decorations that are almost identical to the Retain feature in Arc mode are strong (strong references);

(5). Copy attribute: Assignment, setter method copy an incoming object, case: Generally only used to decorate nsstring;

(6). Nonatomic Characteristics: Non-atomic operation, determines whether the compiler generated setter,getter is atomic operation; situation: improve efficiency;

(7). Atomic Features: Atomic operations, providing multithreading security, preventing threads from being read by other threads when they are not completed (which can result in data errors); Conditions: Actions that cannot be interrupted "note": General use of nonatomic;

2.NSInteger is not a subclass of Nsnumber/nsobject and is the base data type (an alias of Int/long), depending on whether the system is 32-bit or 64-bit to determine whether it is an int or a long.

3. Difference between notice and agreement

The protocol can be seen as a one-to-many understanding of life, but it has a chain of control relationships, and notifications are not. Boss of the work agent is not through the staff, each employee for the boss work, boss to pay for each employee, is not to send cat wages to dog, (it is not a kind of)

Notifications can be one-to-many, a message to multiple recipients, such as financial notice: The company's employees in xx xx point to XX to receive the salary bar. Notifications are only concerned with giving notice.

iOS face question accumulation

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.