保留和复制的区别?

Difference between retain and copy?(保留和复制的区别?)
本文介绍了保留和复制的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

保留和复制之间到底有什么区别?它对引用计数有什么意义?

What exactly is the difference between retain and copy? what is its significance on reference counting?

我知道当使用 alloc/retain 分配对象时,引用计数会增加一.那么如何使用副本?

I know that when an object is allocated using alloc/retain, reference count goes up by one. so how about using copy?

与此相关的另一个问题是,使用之间的区别
@property(nonatomic, retain) 和 @property(nonatomic,copy)?

Another question relating to this is, the difference between using
@property(nonatomic, retain) and @property(nonatomic,copy)?

推荐答案

retain -- 在创建的对象上完成,它只是增加引用计数.

retain -- is done on the created object, it just increase the reference count.

复制——创建一个新对象

copy -- create a new object

这篇关于保留和复制的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to stop UIBarButtonItem text from truncating?(如何阻止UIBarButtonItem文本被截断?)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Unresolved reference: databinding in Android studio 4.1.3(未解析的引用:Android Studio 4.1.3中的数据绑定)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
NSURLSessionTaskPriority seems to be ignored?(NSURLSessionTaskPriority似乎被忽略了?)
How to make dataWithEPSInsideRect vector rather than bitmap in vector format?(如何用EPSInside Rect将dataWithEPSInside Rect变成矢量而不是位图的矢量格式?)