我什么时候使用CFRelease?

Moo*_*Soo 10 iphone xcode objective-c ios

我正在学习iOS编程.

我编写了与地址相关联的代码.

有很多方法.喜欢

我正在分组.

这是group1

ABAddressBookCreate();
ABRecordCopyCompositeName(argument);
ABRecordCopyValue(argument1, argument2);
ABRecordCopyValue(argument1, argument2);
ABMultiValueCopyLabelAtIndex(argument1, argument2);
ABMultiValueCopyValueAtIndex(argument1, argument2);
Run Code Online (Sandbox Code Playgroud)

另一个就在这里,group2

CFArrayGetCount(argument);
CFArrayGetValueAtIndex(argument1, argument2);
ABMultiValueGetCount(argument);
Run Code Online (Sandbox Code Playgroud)

我知道还有很多其他的方法.

但我想知道我什么时候使用CFRelease方法.

我认为group2的所有方法都不做CFRelease

因为它包含单词"Get",未分配.

我认为group1的所有方法都必须使用CFRelease

因为有一个字符串"copy".

我有一本书.

但是有两次使用CFRelease.

一个是发布ABAddressBookCreate()

另一个是ABAddressBookCopyPeopleWithName.

所有其他事情都不使用CFRelease.

所以我想知道我何时使用CFRelease.

当我使用CFRelease时请告诉我.

gra*_*ver 10

如果函数名称包含"复制"或"创建",则您拥有该对象,因此在完成工作后必须将其释放.这称为"创建规则".有关Core Foundation的内存管理的更多信息,请参阅Core Foundation的内存管理编程指南