objective c - Is Block_copy recursive? -
i have code boils down this:
-(void)dosomethingwithblock:(blocktypedef)block { [foo dosomethingelsewithblock:^() { block(); }]; } foo dosomethingelsewithblock: calls block_copy , block_release on block receives. necessary @ outer scope, or inner block_copy handle this?
i quote blocks programming topics guide on apple's developer documentation site:
when copy block, references other blocks within block copied if necessary—an entire tree may copied (from top). if have block variables , reference block within block, block copied.
when copy stack-based block, new block. if copy heap-based block, however, increment retain count of block , returned value of copy function or method.
Comments
Post a Comment