removeObject是否在NSMutableArray对象中

removeObject是否在NSMutableArray对象中

本文介绍了removeObject是否在NSMutableArray对象中释放对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么时候使用removeObject在数组中删除对象,如果删除的对象正确处理。

I was wondering when you remove an object using removeObject in an array if that removed object is handled properly. Would the object being removed be released?

推荐答案

NSMutableArray会释放它。如果这是它的最后一个retain,它将被释放。从文档:

The NSMutableArray will release it. If that's the last retain on it, it will be deallocated. From the documentation:

请参见。它们的例子实际上指的是 removeObjectAtIndex:

See the NSMutableArray documentation. Their example, in fact, refers to removeObjectAtIndex::

id anObject = [[anArray objectAtIndex:0] retain];
[anArray removeObjectAtIndex:0];
[anObject someMessage];

这篇关于removeObject是否在NSMutableArray对象中释放对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 14:56