Learn note from zero-start Swift (DAY60)--core Foundation framework

Source: Internet
Author: User
Tags mixed


Create articles, welcome reprint. Reprint Please specify: Dongsheng's blog  

Core FoundationThe framework is Apple's offering a set of concepts derived fromFoundationframework, programming interface forClanguage-styleAPI. Although inSwiftThis is called in theClanguage-styleAPImore trouble, but inOS Xand theIOSDuring the development process, sometimes usingcorefoundationframework ofAPIis very convenient, such as in theCwhen language is mixed with code.

Core FoundationFramework andFoundationframeworks are closely related and they have the same interface, but different. Core FoundationFramework is based onClanguage-style, andFoundationFramework is based onobjective-clanguage-style.


in the OS X and the IOS in program code, there are often multiple language-style codes mixed together. This makes our development more cumbersome.





Data type Mappings


Core FoundationThe framework provides some opaque data types. These data types encapsulate some data and operations. They can also be called "classes," and they all inherit fromCftypeclass,Cftypeis the useCore Foundationthe root class of the framework type. These data types areFoundationthere are corresponding data types in the framework, and these data types also have someSwiftThe native data type has a corresponding relationship.




Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "/>





SeeSwiftnative type and Core FoundationExamples of conversions between types:



import CoreFoundation

import Foundation

 

var cfstr1: CFString = "Hello, World" // Create a CFString string

 

var str: String = cfstr1 as String // Convert CFString string to Swift native string String

 

var cfstr2: CFString = str // Convert Swift native string to CFString 







During this conversion,Core Foundationtype is converted toSwiftthe native type is required to force type conversions.








Welcome to follow Dongsheng Sina Weibo @ Tony_ Dongsheng.




Learn about the latest technical articles, books, tutorials and information on the public platform of the smart Jie classroom
?


Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "/>
many other boutiqueIOS,Cocos, mobile design courses, please pay attention to the official site of the Smart Jie classroom:http://www.zhijieketang.com
Smart Jie Classroom forum site:http://51work6.com/forum.php






Learn note from zero-start Swift (DAY60)--core Foundation framework


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.