Block variable storage area under different circumstances

Source: Internet
Author: User

I. If you use only global or static variables or do not use external variables, the code for block blocks is stored in the global zone;
Two. If an external variable is used, the code for block blocks in arc is stored in the heap area;
In the MRC, Block fast code is stored in the stack area;
Three. block by default, external variables cannot be modified, only external variables can be read:
In arc, an external variable exists in the heap, which is the same as the address outside block blocks in block blocks;
An external variable exists in the stack, which is copied to the heap allocated for block code blocks;
In the MRC, the external variables exist in the heap, which is the same as the blocks outside the block block;
An external variable exists in the stack, which is copied to the stack allocated for block code blocks;
Four. If you need to modify an external variable, you need to declare it before the external variable __block
In arc, an external variable exists in the heap, which is the same as the block outer address in block blocks;
An external variable exists in the stack, and this variable is transferred to the heap area, not copied, and is transferred.
In the MRC, an external variable exists in the heap, and the variable is the same as the block outer address within the block.
The external variable exists in the stack, and the variable is the same as the block outer address within the block blocks;

Block variable storage area under different circumstances

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.