gpt4 book ai didi

iphone - 我什么时候使用 CFRelease?

转载 作者:技术小花猫 更新时间:2023-10-29 11:02:25 24 4
gpt4 key购买 nike

我正在学习 iOS 编程。

我编写了关联地址的代码。

有很多方法。喜欢

我正在划分一个小组。

这是组1

ABAddressBookCreate();
ABRecordCopyCompositeName(argument);
ABRecordCopyValue(argument1, argument2);
ABRecordCopyValue(argument1, argument2);
ABMultiValueCopyLabelAtIndex(argument1, argument2);
ABMultiValueCopyValueAtIndex(argument1, argument2);

还有一个就在这里,group2

CFArrayGetCount(argument);
CFArrayGetValueAtIndex(argument1, argument2);
ABMultiValueGetCount(argument);

我知道还有很多其他方法。

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

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

因为里面含有“get”字样,所以没有分配。

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

因为有一个字符串“copy”。

我有一本书。

但是有两次使用了 CFRelease。

一个是释放ABAddressBookCreate()

另一个是 ABAddressBookCopyPeopleWithName。

所有其他东西都不使用 CFRelease。

所以我想知道我什么时候使用 CFRelease。

请在我使用 CFRelease 时告诉我。

最佳答案

如果函数名称包含“Copy”或“Create”,那么您拥有该对象,因此您必须在完成对它的工作后释放它。这称为“创建规则”。有关 Core Foundation 的内存管理的更多信息,您可以引用 Memory Management Programming Guide for Core Foundation

关于iphone - 我什么时候使用 CFRelease?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10203990/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com