Toll free bridging, referred to as TFB, is a mechanism that allows some objc classes and their corresponding corefoundation classes to be used interchangeably. For example, nsstring and cfstring are bridged, which means that any nsstring can be used as a cfstring, or any cfstring can be used as an nsstring
There are a number of data types in the core foundation framework and the foundation framework that can be used interchangeably. This capability, called toll free bridging, means that you can use the same data type as the parameter to a core foundation function call or as the receiver of an Objective-C message
The principle (take nsstring as an example) is: nsstring is an abstract class. Whenever you create an instance of nsstring, it is actually a private subclass instance of nsstring. One of the private subclasses is nscfstring, which is the corresponding class of cfstring class in objc. Nscfstring implements all the methods needed as an nscfstring
My understanding: in short, you know that there is a toll free bridging mechanism, and nscfstring is a private subclass of nsstring, which implements all its methods. See the official website for detailed explanation
Why cfstring
Explanation on the official website:
CFString provides a suite of efficient string-manipulation and string-conversion functions. It offers seamless Unicode support and facilitates the sharing of data between Cocoa and C-based programs
On this point, I also recommend a better blog post:
Toll Free Bridging
Similar Posts:
- Java error: No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Access permission problem caused by object. Clone() method
- Android Exception: UncaughtException detected: java.lang.RuntimeException: Parcelable encountered IOExcepti
- [Solved] Cannot make a static reference to the non-static field logMongoTemplate
- Could not open input file: composer.phar
- [Problems with the use of internal classes] No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclo
- Handler dispatch failed; nested exception is java.lang.StackOverflowError
- [Solved] The bean ‘sysDictService’ could not be injected because it is a JDK dynamic proxy
- [Solved] UserInfo()’ in ‘com.example.gmall.cart.pojo.UserInfo’ cannot be applied to ‘(long, java.lang.String)’
- [Solved] SpringBoot Startup Error: is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)