Member Variable scope: OC

Source: Internet
Author: User
Tags variable scope

  1. There are four kinds;
  2. A public scope means that member variables can be accessed everywhere;
  3. A private scope can only be accessed directly from the object methods of the current class, such as PERSON.M; if the subclass needs access, it needs to pass the set and get methods;
  4. Protection scopes can be accessed directly in the object methods of the current class and subclass;
  5. The private variables of the parent class cannot be accessed directly in the subclass, but there are private variables that need to be accessed through the set and get methods;
  6. Do not write anything, the default is protected;
  7. @public: The member variables of an object can be accessed directly from anywhere
  8. @private: can only be accessed directly in the object method of the current class;
  9. @protected: can be accessed directly in the object method of the Money class and subclass (default is @protected)
  10. @package: The member variables of an object can be accessed directly in the same frame;
  11. The member variable in the. h file is protected by default, and the member variable in. m is private by default, even if it is written as @public; The subclass is also private. The member variable name declared in the. m file cannot be the same as the one in the. h file, unless it is placed in the. main file for direct access;
  12. Super class is the parent class superclass

Member Variable scope: OC

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.