What's the difference between Objective-C and Cocoa?

后端 未结 4 1692
日久生厌
日久生厌 2021-01-31 02:21

I\'m just learning Objective-C/Cocoa programming for the Mac. All of the tutorials, books, blogs, podcasts, etc. I\'ve been using really cover the two together. Is there an ea

相关标签:
4条回答
  • 2021-01-31 02:57

    Objective-C is the language... it defines all the things like the keywords for defining objects, the syntax for messaging object, things like that.

    Cocoa is a development framework (it's actually an umbrella framework which combines three other frameworks, Foundation, AppKit and CoreData).

    These frameworks (Cocoa) define all the objects that are nice to use and interact with the operating system, as well as a number of functions. For example, Cocoa defines things like NSString and NSObject. Cocoa can currently be used with other language bindings, such as python or ruby, and used to be used with Java as well. So, if you were using Cocoa with Java, you would still get an NSString object, but you would call and use it from within a Java application.

    Without linking to one of the Cocoa frameworks, Objective-C comes with only a very basic Object class as a pre-defined root class.

    0 讨论(0)
  • 2021-01-31 03:01

    Sure, it is quite easy - Objective-C is the language, Cocoa is the API/library you are using to build you Mac App.

    0 讨论(0)
  • 2021-01-31 03:08

    Objective-C is the language itself.

    Cocoa, formerly NextStep, is the API and runtime that sits on top of Obj-C. Anything starting with NS (for NextStep) is part of Cocoa, not part of the language.

    0 讨论(0)
  • 2021-01-31 03:15

    Look in /usr/include/objc/ — in there is pure Objective-C. Everything else is Cocoa. You might notice you almost never directly use anything in there.

    However, in practice it makes little difference. Cocoa is the de facto Objective-C standard library. The only platform where Objective-C is used without Cocoa is Portable Object Compiler, and I'm guessing maybe three people still use that.

    0 讨论(0)
提交回复
热议问题