English 中文(简体)
关于再分配物体的信息
原标题:Info about re-alloc of an object

我有问题...... 例如,如果我有一架NSMutableArray,如果我使用该编号的话,那么,如果我使用该编号的话,那就用了100个物体。

mutablearray=[NSMutableArray alloc]init];

and add at the array others 100 objects... the first 100 object was deallocated (so the memory is free) or I must do [mutablearray release] to free memory? thanks

最佳回答

if mutablearray is retained or using through copy property then surely you need to release it. And if you are not using mutablearray as property then you will need to look into the following: Adding an object to an NSMutableArray increases it s retain count by one, giving it a retain count of 2 (1 for the alloc/init, and one for adding to the array).

so removeAllObject will take care of increased retaincount for the array and you need not to worry. Just call: [mutablearray removeAllObjects];

问题回答

You need or remove all objects from your array. In this case you don t need new array. Or release array, at release array releases all it s objects.

You have to use [mutablearray release] to free memory because releasing the objects doesn t release the internal structures of the array. Also, you shouldn t release objects in the array, instead remove them from the array by using any of the remove... commands of NSArray





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签