What is the main difference using “copy” and “strong” ownership qualifiers in property declaration with block types?

寵の児 提交于 2019-12-13 12:18:05

问题


Example #1

@property (nonatomic, copy) void (^errorBlock) (NSError *);

Example #2

@property (nonatomic, strong) void (^errorBlock) (NSError *);

I know that blocks are standard variables on stack, and by making a copy we are "moving" them to the heap.

Thats all? Or not?


回答1:


There should be no difference. Since the property has a block type, according to http://clang.llvm.org/docs/AutomaticReferenceCounting.html#blocks

With the exception of retains done as part of initializing a __strong parameter variable or reading a __weak variable, whenever these semantics call for retaining a value of block-pointer type, it has the effect of a Block_copy.



来源:https://stackoverflow.com/questions/16426382/what-is-the-main-difference-using-copy-and-strong-ownership-qualifiers-in-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!