使用NSArray对象引用,我是否显式释放数组中的所有对象或仅释放数组本身? [英] With an NSArray of object references, do I explicitly release all objects in the array or just the array itself?

查看:99
本文介绍了使用NSArray对象引用,我是否显式释放数组中的所有对象或仅释放数组本身?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的班级有一个充满了物体的NSArray。在我的dealloc方法中,我可以简单地在我的NSArray上调用release,还是我需要迭代数组并首先释放所有对象?

My class has an NSArray that is filled with objects. In my dealloc method, can I simply call release on my NSArray, or do I need to iterate the array and release all objects first?

推荐答案

您可以直接在 NSArray 上调用release。 NSArray 的实现将负责向存储在数组中的所有对象发送 release

You can call release directly on the NSArray. The implementation of NSArray will take care of sending release to all the objects stored in the array.

这篇关于使用NSArray对象引用,我是否显式释放数组中的所有对象或仅释放数组本身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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