Iâm glad youâre making progress here.
Why did the authors do this?
The answer is rooted in history [1].
One key goal of Mac OS X was a smooth transition from Mac OS 9. Mac OS 9 didnât have Objective-C, so Foundation wasnât available there. However, many APIs that were going to be shared between Mac OS 9 and Mac OS X needed Foundation âcurrencyâ types, for things like data and strings. To solve this, we rewrote the core of these currency types in C, published that as Core Foundation, and rehosted the Objective-C types of top of those [2].
To make this easier on the Mac OS X side, these currency types were toll-free bridged to their Foundation equivalents. For example, CFData is toll-free bridged to NSData, CFString to NSString, and so on. See see Toll-Free Bridged Types within Core Foundation Design Concepts in the Documentation Archive.
When Swift was introduced one of its key goals was interoperability with Objective-C. Thus itâs easy to convert between Swiftâs Data and Foundationâs NSData, and from there CFData
Core Graphics dates to the very beginning of the Mac OS X project. Within Mac OS X there was a low-level layer that could not use Objective-C [3]. Core Graphics was part of that layer. Given that, it has to use Core Foundation âcurrencyâ types.
Image I/O was introduced slightly later, but it has similar restrictions.
"public" only!.
Iâm not sure what you mean by this, but I wanted to explain how youâd use a UTType in this context, namely:
CGImageDestinationCreateWithData(âŚ, UTType.png.identifier as CFString, âŚ)
Share and Enjoy
Quinn âThe Eskimo!â @ DTS @ Apple
[1] Normally I donât answer why questions â see tip 3 in Quinnâs Top Ten DevForums Tips â but in this case weâre well past the statute of limitations (-:
[2] Note that this was historically true but is no longer true. In the intervening 25 years this has changed twice, with the core implementations moving first to Objective-C and then to Swift. If youâre curious, check out Tonyâs talk on this.
[3] Part of the rationale for that was that Objective-C means Foundation and Foundation had a constant and not-insubstantial overhead. Bringing that in to every process was problematic.