iOS Understanding-Pro mutlithreading and Memory Management for IOS and OS X with ARC, Grand Central Dispatch, and Blocks

Source: Internet
Author: User

Capturing automatic variables

Next, you need to learn what's the "Together with automatic (local) variables" part means.
For Blocks, this can is rephrased as "capturing the value of automatic variables." The
Next example shows how thiscapture is accomplished.

When automatic variables is captured, the values is read-only in the Block. The
Variables can ' t be modified.

Blocks is "anonymous
Functions together with automatic (local) variables.

Isa

A struct for each class was a class_t struct based on objc_class struct. The class_t struct
is declared at Runtime/objc-runtime-new.h in the OBJC4 Runtime library.
struct class_t {
struct class_t *isa;
struct class_t *superclass;
Cache cache;
IMP *vtable;
uintptr_t Data_never_use;
};

The implementation of a block is as follows:

Next, let's see the implementation of the anonymous function that uses the Block. The
Original Block literal is as follows.
^{printf (FMT, Val);}
This is the converted to a function.
static void __main_block_func_0 (struct __main_block_impl_0 *__cself)
{
const char *FMT = __cself->fmt;
int val = __cself->val;
printf (FMT,

iOS Understanding-Pro mutlithreading and Memory Management for IOS and OS X with ARC, Grand Central Dispatch, and Blocks

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.