Dark Horse programmer--"Dark Horse video Notes" OC Language foundation using Property optimization Package

Source: Internet
Author: User

1.property function Usage
   1:  //@property: Setter and getter declarations that can automatically generate a member variable
   2:  int age;  The declaration of a variable can be dispensed with directly
   3:  //-(void) Setage: (int) age;
   4:  //-(int) age;

2. Attention points

If you use the property but write your own get or set method, your own writing will overwrite the corresponding method of the system.

   1:  -(void) Setage: (int) age
   2:  {
   3:  
   4:  }
   5:  
   6:  //-(int) age
   7:  //{
   8:  //    
   9:  //}
  Ten:  
One   :  //-(int) age
  :  //{
  :  //    return;
  :  //}

1.set method Memory management-related parameters
* Retain:release old value, retain new value (for OC object type)
* Assign: Direct assignment (default, for non-OC object types)
* Copy   : Release old value, copy new value
2. Whether to generate a set method
* ReadWrite: Generate both setter and Getter Declaration, implementation (default)
readonly  : Only generate getter declarations, implementations
3. Multithreading Management
* Nonatomic: High performance (usually with this)
* Atomic    : Low performance (default)
The name of the 4.setter and Getter methods
* Setter: Determines the name of the set method and must have a colon:
* Getter: Determines the name of the Get method (typically used in bool type)

Dark Horse programmer--"Dark Horse video Notes" OC Language foundation using Property optimization Package

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.