NSString 实例将其类报告为 NSCFString [英] NSString instance reports its class as NSCFString
问题描述
我在这里的目标非常简单——我试图将一个 NSString
设置为一些测试数据,然后返回应该是 NSString
的类.这是我的代码:
My objective here is really simple -- I'm trying to set an NSString
to some test data, then return the class, which should be NSString
. Here's my code:
NSString* stringer = [NSString stringWithFormat: @"Test"];
NSLog(@"%@", [stringer class]);
日志说这个类是NSCFString
,而不是NSString
.这是怎么回事?
The log says that the class is NSCFString
, not NSString
. What's going on here?
推荐答案
NSString 实际上是一个用于不同类型字符串对象的容器类.通常,NSString 构造函数确实返回一个实际上是 NSCFString 类型的对象,它是 Core Foundation CFString 结构体的薄包装.
NSString is really a container class for different types of string objects. Generally an NSString constructor does return an object that is actually of type NSCFString, which is a thin wrapper around the Core Foundation CFString struct.
这篇关于NSString 实例将其类报告为 NSCFString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!