NSCFString和NSConstantString有什么区别? [英] What is the different between NSCFString and NSConstantString?
问题描述
我将对象变量声明为NSString
但是当我使用XCode来查看对象时,我看到有两种类型的String,看来系统会自动转移到另一种类型:
I declare the object variable as a NSString
But when I use the XCode to look into my object, I saw there are two type of String, it seems that the system automatically transfer to another:
它们之间有什么区别?它们可以彼此互换吗?另外,两个条件变为另一个条件是什么?
What are the different between them? Are they interchangeable to one and others. Also, what is the condition two change to another?
谢谢.
推荐答案
它们都是NSString
的具体子类. __NSCFString
是在运行时通过Foundation或Core Foundation创建的,而__NSCFConstantString
是在编译时创建的CFSTR("...")
常量或@"..."
常量.
They're both concrete subclasses of NSString
. __NSCFString
is one created during runtime via Foundation or Core Foundation, while __NSCFConstantString
is either a CFSTR("...")
constant or an @"..."
constant, created at compile-time.
它们的接口是私有的.将它们都视为NSString
,您应该不会遇到麻烦.
Their interfaces are private. Treat them both as NSString
and you should have no trouble.
这篇关于NSCFString和NSConstantString有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!