What does the NS prefix mean?

前端 未结 9 1006
别跟我提以往
别跟我提以往 2020-12-02 03:32

Many classes in Cocoa/Cocoa Touch have the NS prefix. What does it mean?

9条回答
  •  遥遥无期
    2020-12-02 04:13

    From Apple's developer docs:

    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.

    Source: Programming with Objective-C

提交回复
热议问题