- Mastering macOS Programming
- Stuart Grimshaw
- 277字
- 2021-07-02 22:54:42
Cocoa Frameworks - The Backbone of Your Apps
We suggested a metaphor in Chapter 1, Hello macOS, making a comparison between an artist's brushes and paints and the frameworks available to the macOS developer through Cocoa. In this chapter, we'll take a look at some of the concepts we will need to make effective and creative use of all the tools that Cocoa puts at our disposal. Like using any tool, using Cocoa's frameworks means being aware of how they work and how they were intended to be used. This is not to say that macOS development is nothing more than learning to connect up a few pre-prepared framework objects, far from it. The very power of Cocoa is that it gives you an enormous amount of control over its seemingly innumerable features, allowing you to dive deeply into the nuts and bolts wherever you need that level of access.
But it does mean adhering to some ground rules as a kind of default strategy, and veering away from that when you have good reason to. You won't become the best developer you can be without a firm grip on Cocoa's way of doing things.
If that sounds a little restrictive, remember that Johann Sebastian Bach, Brian Eno, and Jimi Hendrix used the same twelve notes, but sound, well, slightly different.
In this chapter, you will learn the following:
- The significance and features of Foundation Kit
- How to make your classes a subclass of NSObject, and why you'd want to
- Importing Foundation, AppKit, or Cocoa
- How to make your classes compliant with key-value coding
- How to use Cocoa bindings to remove a large amount of UI synchronization code