我用这段代码定义了一个块:
void(^blockA)(void) = ^{
NSLog(@"just a block");
};
NSLog(@"%@", blockA);
打印:
DeepCopy[22740:832979] <__NSGlobalBlock__: 0x100002150>
这个打印显示该块是全局块,但是当我把它变成c ++代码时,它显示这个块是一个带有上面代码的堆栈块:
struct __main_block_impl_0 {
struct __block_impl impl;
struct __main_block_desc_0* Desc;
__main_block_impl_0(void *fp, struct __main_block_desc_0 *desc, int flags=0) {
impl.isa = &_NSConcreteStackBlock;
impl.Flags = flags;
impl.FuncPtr = fp;
Desc = desc;
}
};
块为何不同?