English 中文(简体)
记忆管理:如果一个制版方法回落空,我是否应当释放?
原标题:memory management: should I release if a Copy method returns empty?

I call ABAddressBookCopyPeopleWithName(book, fullname); which is supposed to return an array of ABRecords for all the names that match fullname from the AddressBook. Since this has a Copy in it s name, it s returning with a retain count of 1 which I should release. What if it couldn t find any matching names? Should I still release it? Is the empty object set to nil? Or is it just empty, and calling release will cause a crash?

最佳回答

Yep,如果其名称为“Copy”,你应将其释放。 如果它回到一系列的ABRecords,它就把自己保留给你们。 如果阵列空,找不到名字,你仍需要释放。

虽然如此,我没有利用这一职能,而且这个机会可能是一 case,不遵循可可命名公约。 检查,采用这种方法,然后说:

NSLog(@"%d", [resultArray retainCount]);

这将告诉你,保留阵列是什么,因此,你可以百分之百地确保你在必要时释放。

希望帮助!

问题回答

暂无回答




相关问题
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风格的解决办法,只是一个简单的袖珍流程......

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

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

热门标签