使用“复制"功能的主要区别是什么?和“强"具有块类型的属性声明中的所有权限定符? [英] What is the main difference using "copy" and "strong" ownership qualifiers in property declaration with block types?

查看:90
本文介绍了使用“复制"功能的主要区别是什么?和“强"具有块类型的属性声明中的所有权限定符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例1

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

示例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.

仅此而已?还是不?

推荐答案

应该没有区别.由于该属性具有块类型,因此根据 http://clang.llvm.org/docs /AutomaticReferenceCounting.html#blocks

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

除了保留是初始化__strong的一部分之外 参数变量或读取__weak变量,只要这些 语义要求保留块指针类型的值,它具有 Block_copy的效果.

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.

这篇关于使用“复制"功能的主要区别是什么?和“强"具有块类型的属性声明中的所有权限定符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆