IOS Local Variables global variable member variable

Source: Internet
Author: User

A. Member variable: A variable written in curly braces of a class declaration is called a member variable (also called a property/instance variable)

Member variable cannot leave class leave class is not member variable

member variables can no longer be defined by colleague initialization

The number of members can only be accessed through objects

Member variables are stored in the heap (the current object corresponds to the heap of storage space) will not be automatically released by the system can only be manually released by the programmer

Two. Local variables: Variables written in code blocks or functions are local variables

Scope of a local variable: Start with the defined line, until you encounter curly braces or return (that is, the code block or function at the end of the variable)

A local variable can be initialized before it is defined, or it can be initialized at the same time as the definition.

local variables are stored inside the stack and the system is automatically released .

Three. Global variable: A variable outside the Unload function or outside the curly brace is a global variable

Scope of global variables: from the definition of which line to the end of the file

A global variable can be initialized to a definition, or it can be initialized at the same time as defined.

Global variables are stored in the static zone when the program starts, it allocates storage space until the program ends to release

IOS Local Variables global variable member variable

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.