保留和复制的区别?

2024-04-15移动开发问题
6

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

问题描述

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

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

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

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

如何将 32 位 PNG 转换为 RGB565?
How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)...
2024-08-12 移动开发问题
21

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7

游戏中心 facebook 喜欢
Game center facebook like(游戏中心 facebook 喜欢)...
2024-08-12 移动开发问题
3