我什么时候使用CFRelease? [英] When do I use CFRelease?

查看:116
本文介绍了我什么时候使用CFRelease?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习iOS编程。

i'm studying iOS programming.

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

i wrote code that associated an address.

有这样的很多方法。喜欢

there's so many methods. like

我正在分组。

这里的group1

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

另一个就在这里,group2

and another one is right here, group2

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

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

i know there's so many other methods.

但我想知道我何时使用CFRelease方法。

but i wonder when i use CFRelease method.

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

i think group2's all methods don't do CFRelease

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

because that contain the word "Get", not allocated.

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

and i think group1's all method have to use CFRelease

因为有一个字符串copy。

because there's a string "copy".

我有一本书。

但是有使用CFRelease两次。

but there's used CFRelease twice.

一个是发布ABAddressBookCreate()

one is release ABAddressBookCreate()

另一个是ABAddressBookCopyPeopleWithName。

another one is ABAddressBookCopyPeopleWithName.

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

all of other things don't use CFRelease.

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

so i wonder when i use CFRelease.

请在使用CFRelease时告诉我。

please tell me when i use CFRelease.

推荐答案

如果函数名称包含复制或创建 ,那么你拥有这个对象,所以当你完成它的工作时你必须释放它。这称为创建规则。有关Core Foundation内存管理的更多信息,请参阅核心基金会内存管理编程指南

If the function name contains "Copy" or "Create", then you own the object, so you must release it when you finish your work with it. This is called "The Create Rule". For more information on Memory management for Core Foundation, you can refer to Memory Management Programming Guide for Core Foundation

这篇关于我什么时候使用CFRelease?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆