gpt4 book ai didi

CoreFoundation 所有权遵循 CreateRule

转载 作者:太空宇宙 更新时间:2023-11-03 23:35:13 26 4
gpt4 key购买 nike

什么是“所有权遵循 CreateRule”。意味着在核心基础文档中?。

Return Value A new dictionary, or NULL if there was a problem creating the object. Ownership follows the Create Rule.

谢谢。

最佳答案

如果您创建一个对象,使用名称中带有CreateCopy 的函数,您需要使用 CFRelease 释放它。如果您通过其他方式获得对象,则不必这样做。

与 Objective-c 中的便捷方法相同。

引自“核心基础设计概念”

There is an important distinction between Get, and Copy and Create, in names of functions that return values. If you use a Get function, you cannot be certain of the returned object’s life span. To ensure the persistence of such an object you can retain it (using the CFRetain function) or, in some cases, copy it. If you use a Copy or Create function, you are responsible for releasing the object (using the CFRelease function). For more details, see Memory Management Programming Guide for Core Foundation.

关于CoreFoundation 所有权遵循 CreateRule,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5718415/

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