Cocoa/Cocoa Touch中的许多类都有NS前缀。这是什么意思?


当前回答

它是NextStep (= NS)遗产。NeXT是乔布斯1985年离开苹果公司后成立的电脑公司,NextStep是它的操作系统(基于UNIX)以及Obj-C语言和运行时。NextStep连同它的库和工具,后来被重新命名为OpenStep(这也是NeXT和Sun一起开发的API上的名字),后来又变成了Cocoa。

这些不同的名字实际上很让人困惑(特别是因为有些名字只在字符是大写或小写时才不同..),尝试下面的解释:

TheMerger OpenstepConfusion

其他回答

NeXTSTEP或NeXTSTEP/Sun取决于你问的是谁。

有一段时间,Sun在OpenStep上有相当大的投资。在Sun加入之前,基金会中的大多数东西,尽管当时还不叫基金会,前缀都是NX,代表NeXT,在Sun加入之前的某个时候,所有东西都被重命名为NS。S很可能并不代表Sun,但在Sun加入后,人们普遍认为它代表Sun,以纪念他们的参与。

实际上我有一个参考资料,但我现在找不到。如果/当我再次找到它时,我会更新这篇文章。

它是NextStep (= NS)遗产。NeXT是乔布斯1985年离开苹果公司后成立的电脑公司,NextStep是它的操作系统(基于UNIX)以及Obj-C语言和运行时。NextStep连同它的库和工具,后来被重新命名为OpenStep(这也是NeXT和Sun一起开发的API上的名字),后来又变成了Cocoa。

这些不同的名字实际上很让人困惑(特别是因为有些名字只在字符是大写或小写时才不同..),尝试下面的解释:

TheMerger OpenstepConfusion

当NeXT定义NextStep API(与NextStep操作系统相反)时,他们使用了前缀NX,如NXConstantString。当他们使用Sun(不要与OpenStep操作系统混淆)编写OpenStep规范时,他们使用了NS前缀,就像在NSObject中一样。

它来自NeXTSTEP传统。

来自Cocoa_(API)维基百科:

(重点)

Cocoa classes begin with the acronym "NS" (standing either for the NeXT-Sun creation of OpenStep, or for the original proprietary term for the OpenStep framework, NeXTSTEP): NSString, NSArray, etc. Foundation Kit, or more commonly simply Foundation, first appeared in OpenStep. On Mac OS X, it is based on Core Foundation. Foundation is a generic object-oriented library providing string and value manipulation, containers and iteration, distributed computing, run loops, and other functions that are not directly tied to the graphical user interface. The "NS" prefix, used for all classes and constants in the framework, comes from Cocoa's OPENSTEP heritage, which was jointly developed by NeXT and Sun.