Objective-C解疑:爲什麼是NS、UI開頭?

Objective-C簡稱OC,是擴充自C語言的面向對象編程語言。

1 OC語言是蘋果OS X 和IOS系統的主要編程語言
2 喬布斯NeXT公司,OC語言庫和NEXTSTEP開發環境
3 NeXT軟件成爲Mac電腦和IOS操作系統的基礎

問:爲什麼是NS開頭呢?

答:IOS中大多數的NS前綴的類是NeXTSTEP操作系統中Foundation框架裏的一部分,而該操作系統是OS X的基礎,NS的前綴是NeXT和Sun合作創建OpenStep之後被改爲NS,OpenStep是一個面向對象的框架,它被用來在其他平臺上提供類似於NeXTSTEP的環境。
通俗點:NS是NeXT和Sun兩個字母的簡稱。

問:爲什麼是UI開頭呢?

for User Interface elements on iOS

以下是蘋果官方文檔:

Historical Note: If you’re wondering why so many of the classes you encounter have an NS prefix, it’s because of the past history of Cocoa and Cocoa Touch. Cocoa began life as the collected frameworks used to build apps for the NeXTStep operating system. When Apple purchased NeXT back in 1996, much of NeXTStep was incorporated into OS X, including the existing class names. Cocoa Touch was introduced as the iOS equivalent of Cocoa; some classes are available in both Cocoa and Cocoa Touch, though there are also a large number of classes unique to each platform.

Two-letter prefixes like NS and UI (for User Interface elements on iOS) are reserved for use by Apple.

更多文章查看個人主頁:
Github搭建個人博客(2019最新版,親測)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章