The difference between Core Foundation and Cocoa Foundation framework

Source: Internet
Author: User
The Core Foundation Framework (corefoundation.framework) is a set of C language interfaces that provide basic data management and service functionality for iOS applications. The data that the framework supports for management and the services available are listed below:

Group data types (arrays, collections, etc.)

Program Package

String Management

Date and time management

RAW Data Block Management

Preference Management

URL and Data flow operations

Threads and Runloop

Port and Soket Communication

The Core Foundation framework is closely related to the foundation framework, which provides interfaces for the same functionality, but the foundation framework provides OBJECTIVE-C interfaces. If you use the foundation object with the core foundation type, you can take advantage of the "toll-free bridging" between the two frames. The so-called toll-free bridging is that you can use certain types in the core Foundatio and foundation frameworks at the same time in a framework's methods or functions. Many data types support this feature, including group and string data types. The class and type descriptions for each framework are explained by whether an object is toll-free bridged, and what object is bridged.

For further information, please read the core Foundation Framework reference.


Objective-c the transition between the pointer and the corefoundation pointer

Arc only manages objective-c pointers (retain, release, autorelease), does not manage corefoundation pointers, and CF pointers are managed manually by manual cfretain and cfrelease, note, There is no autorelease in cf.

Cocoafoundation pointer and corefoundation pointer conversion, you need to consider the ownership of the object pointing to the attribution. ARC provides 3 modifiers to manage.

1. __bridge, nothing is done, just a conversion. In this case:

i). Converting from cocoa to core requires manual cfretain, otherwise the pointer is not available when the cocoa pointer is released.

II. Converting from core to cocoa requires manual cfrelease, otherwise, the object reference count is still 1 after the cocoa pointer is released and will not be destroyed.

2. __bridge_retained, the conversion automatically calls the Cfretain, that is to help automatically solve the above I situation.

2. __bridge_transfer, the conversion automatically calls the Cfrelease, that is to help automatically solve the above II situation.

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.