Core Foundation Framework (2) naming conventions, introspection

Source: Internet
Author: User

The most important of the naming rules is create rule, which is officially stated as follows:

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

That is, if the object is returned by a Get method (rather than a pointer, the pointer returned by the GET function in the corresponding cocoa), you do not need to be responsible for the release of the object, but it does not guarantee the object's life cycle. If it is a create or copy-generated object, the life cycle is guaranteed, but the release is responsible.

Some function names are called createcopy, which means that the first parameter needs to pass in an allocator.

Some functions need to support polymorphism, such as cfcopydescription,cfshow and so on, which is required to pass in the parameter is the Cftype type in order to ensure polymorphism.

The general function is defined as follows:

Cfstringref cfcopydescription (cftyperef CF);

void cfshow (cftyperef obj);

and Cftyperef is simply defined as: typedef const void * CFTYPEREF;

Core Foundation Framework (2) naming conventions, introspection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.