automatic ref counting - Access Stack Block from within Block using ARC in Objective-C -


my question regards blocks in objective-c: assume following situation (with arc enabled):

typedef nsstring*(^myblocktype)(); typedef nsstring*(^myreturnblocktype)(myblocktype);  - (myreturnblocktype) foo: (myblocktype) block {     return ^nsstring*(myblocktype someblock) {         return someblock();     }; } 

the parameter block received method foo: used within block returned method. however, keeps strong reference block? should foo: copy block before returning myreturnblocktype-block? insight appreciated.

  1. the parameter block not used anywhere in code.

  2. let's supposed meant use block inside someblock. variables of object pointer type captured block retained when block copied. furthermore, variables of block pointer type captured block copied when block copied. so, when someblock copied, block copied.

  3. in arc, stack block returned directly automatically copied before returning. thus, someblock, , block, caused copied.

  4. no, foo: not need explicitly copy block, because not doing explicitly store (in instance variable or something).


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -