What is the main difference using “copy” and “stro

2019-04-14 15:59发布

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条回答
叼着烟拽天下
2楼-- · 2019-04-14 16:41

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.

查看更多
登录 后发表回答