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