objective c - Does -[NSInvocation retainArguments] copy blocks? -
nsinvocation
's -retainarguments
method useful when don't run nsinvocation
immediately, later; retains object arguments remain valid during time.
as know, block arguments should copied instead of retained. question is, -retainarguments
know copy instead of retain argument when it's of block type? documentation not indicate does, seems easy , sensible thing do.
update: behavior seems have changed in ios 7. tested this, , in ios 6.1 , before, -retainarguments
didn't copy parameters of block type. in ios 7 , later, -retainarguments
copy parameters of block type. documentation of -retainarguments
has been updated copies blocks, not when behavior changed (which dangerous people support older os's).
it's supposed (albeit haven't test myself). according documentation:
retainarguments
if receiver hasn’t done so, retains target , object arguments of receiver , copies of c-string arguments , blocks.
- (void)retainarguments
discussion
before method invoked, argumentsretained returns no; after, returns yes.
for efficiency, newly created nsinvocation objects don’t retain or copy arguments, nor retain targets, copy c strings, or copy associated blocks. should instruct nsinvocation object retain arguments if intend cache it, because arguments may otherwise released before invocation invoked. nstimer objects instruct invocations retain arguments, example, because there’s delay before timer fires.
Comments
Post a Comment