NSString实例报告其类为NSCFString [英] NSString instance reports its class as NSCFString
本文介绍了NSString实例报告其类为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屋!
查看全文