📜 ⬆️ ⬇️

The Cocoa Environment. Part 1

Many people talk about it, but what place really occupies the Cocoa environment in the life of iOS and MacOS, and indeed what kind of street magic is this?

Welcome Cocoa!


Cocoa is the main application environment for Mac OS X (there is also Carbon, but this environment is mainly used only to support code written for Mac OS 9.) and the only application environment for IOS operating systems. It consists of a set of object-oriented libraries, a runtime, and a development environment.
Most of the programs that Mac OS X users use (for example, Mail or Safari), and even more so, iOS users, are programs written using Cocoa.
Well, to create applications for Cocoa using the famous Xcode.

How and with what?


As in all application environments, Cocoa has two worlds: the world of runtime and development world. In the runtime world, Cocoa applications represent a user interface and tight integration with other components of the operating system on Mac OS X, for example, Finder and Dock.
But in the Cocoa development world, an integrated set of object-oriented software components-classes that, in fact, allow you to create software under Mac OS X and IOS. They make it possible to make a cloud of things, from the user interface to managing data arrays.
While developing Cocoa applications, in fact, you can use several programming languages, but the native language is Objective-C, which is an extension of ANSI C, with some syntactic and semantic features (based on Smalltalk) to support OOP. In addition, your code can call functions defined in the non-Cocoa interface, such as the BSD libraries in / usr / include. You can even mix C ++ code with Cocoa code and reference this compiled miracle in your executable file.
The most important Cocoa libraries are packaged in two basic frameworks for each platform: AppKit for Mac OS X and UIKit for IOS. Like all frameworks, they contain not only dynamically available libraries (and sometimes several versions of libraries needed for backward compatibility), but also header files, API documentation, and associated resources. Framework is a very important component for any project under Mac or IOS.
Mac OS X also supports many other useful libraries, such as: WebKit and Address Book frameworks, but more on that later.
')

And how is Cocoa friendly with Mac OS X?


Architecturally, Mac OS X is a series of software layers (Figure 1).


Figure 1. That's so friendly with Mac OS X

For example, the system component, which is largely responsible for the operation of the Aqua-Quartz interface (implemented in the Core Graphics framework), is part of the Application Services layer. But at the bottom of it all lies Darwin (a set of basic components used in Mac OS X and iOS). everything in Mac OS X, including Cocoa, ultimately depends on this layer.
In Mac OS X, Cocoa consists of two main frameworks that are required for developing applications for Mac OS X:

AppKit depends on Foundation, which is functionally located in the Core Services layer. Looking closer at the AppKit classes, you can see where Cocoa depends on other parts of Mac OS X, such as Carbon Core, Core Graphics (Quartz), and Launch Services.

Apple carefully designed Cocoa so that some of its programming interfaces give access to the basic functions that applications typically need. But if some features are required that are not
available through Cocoa interfaces, or if you need a finer control over what happens in the application, you can directly use the basic framework (a vivid example is Core Graphics, by calling the functions of which you can get more powerful graphics controls).

And how is Cocoa friendly with iOS?


The iOS runtime layer is called Cocoa Touch. Although the iOS infrastructure in which Cocoa Touch works is similar to the one in which Cocoa works in Mac OS X, there are some significant differences (Figure 2).


Figure 2. So is friends with iOS

Typically, the system libraries and frameworks of IOS that UIKit uses are a subset of Mac OS X libraries and frameworks. However, due to the nature of devices supported by IOS,
There are some frameworks that are specific to IOS.
The following is a summary of some of the frameworks of each layer:

Cocoa on iOS, like Cocoa on Mac OS X, gives apps access to basic features. And if you need more than what the Cocoa API provides, you can also directly use lower level methods.

Source - Cocoa Fundamentals Guide

Source: https://habr.com/ru/post/117832/


All Articles