
The Cocoa Environment. Part 1
Many people talk about this, but what really takes the place of Cocoa environment in the life of iOS and MacOS, and indeed what kind of street magic is it?
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 environment, and a development environment.
Most programs used by Mac OS X users (such as Mail or Safari), and even more so iOS users, are programs written using Cocoa.
Well, to create applications for Cocoa, the famous Xcode is used.
As with all application environments, Cocoa has two worlds: the runtime world and the development world. In the runtime world, Cocoa applications provide a user interface and tight integration with other operating system components in Mac OS X, such as Finder and Dock.
But in the development world, Cocoa is an integrated set of object-oriented software component classes that, in fact, allow you to create software for Mac OS X and IOS. They make it possible to do a bunch of things, from the user-interface to managing data arrays.
When 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 main frameworks for each platform: AppKit for Mac OS X and UIKit for IOS. Like all frameworks, they contain not only dynamically accessible libraries (and sometimes several versions of libraries necessary for backward compatibility), but also header files, API documentation, and related resources. Framework is a very important component for any project under Mac or IOS.
Mac OS X also supports many more useful libraries, such as WebKit and Address Book frameworks, but more on that later.
Architecturally, Mac OS X is a series of software layers (Figure 1).

Figure 1. This is how Mac OS X makes friends.
For example, the system component that is largely responsible for the operation of the Aqua interface, Quartz (implemented in the Core Graphics framework), is part of the Application Services layer. But at the heart of all this is Darwin (the set of core components used in Mac OS X and iOS). everything on Mac OS X, including Cocoa, ultimately depends on this layer.
On Mac OS X, Cocoa consists of two main frameworks that are necessary for developing applications for Mac OS X:
AppKit is dependent on Foundation, which is functionally located in the Core Services layer. If you look closely 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 has carefully designed Cocoa so that some of its programming interfaces provide access to the basic functions that applications typically need. But if you need some features that are not
available through Cocoa interfaces, or if you need finer control over what is happening in the application, you can directly use the main frameworks (a striking example is Core Graphics, by calling functions you can get more powerful ones graphics controls).
The iOS app execution layer is called Cocoa Touch. Although the iOS infrastructure on which Cocoa Touch runs is similar to the one on which Cocoa runs on Mac OS X, there are some significant differences (Figure 2).

Figure 2. That's how iOS is friends.
As a rule, the system libraries and iOS frameworks that UIKit uses are a subset of the libraries and frameworks of Mac OS X. However, due to the nature of the devices supported by iOS,
there are some frameworks which are specific to iOS.
The following is a summary of some of the frameworks for each layer:
Cocoa on iOS, just like Cocoa on Mac OS X, gives applications access to basic functionality. And if you need something more than what the Cocoa API provides, you can also directly use lower-level methods.
Source - Cocoa Fundamentals Guide
Greet 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 environment, and a development environment.
Most programs used by Mac OS X users (such as Mail or Safari), and even more so iOS users, are programs written using Cocoa.
Well, to create applications for Cocoa, the famous Xcode is used.
How and with what?
As with all application environments, Cocoa has two worlds: the runtime world and the development world. In the runtime world, Cocoa applications provide a user interface and tight integration with other operating system components in Mac OS X, such as Finder and Dock.
But in the development world, Cocoa is an integrated set of object-oriented software component classes that, in fact, allow you to create software for Mac OS X and IOS. They make it possible to do a bunch of things, from the user-interface to managing data arrays.
When 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 main frameworks for each platform: AppKit for Mac OS X and UIKit for IOS. Like all frameworks, they contain not only dynamically accessible libraries (and sometimes several versions of libraries necessary for backward compatibility), but also header files, API documentation, and related resources. Framework is a very important component for any project under Mac or IOS.
Mac OS X also supports many more useful libraries, such as WebKit and Address Book frameworks, but more on that later.
And how is Cocoa friends with Mac OS X?
Architecturally, Mac OS X is a series of software layers (Figure 1).

Figure 1. This is how Mac OS X makes friends.
For example, the system component that is largely responsible for the operation of the Aqua interface, Quartz (implemented in the Core Graphics framework), is part of the Application Services layer. But at the heart of all this is Darwin (the set of core components used in Mac OS X and iOS). everything on Mac OS X, including Cocoa, ultimately depends on this layer.
On Mac OS X, Cocoa consists of two main frameworks that are necessary for developing applications for Mac OS X:
- AppKit AppKit, one of the components of the application framework, provides an on-screen display of the application and defines the structure of application behavior, including event handling.
- Foundation, a component in the Core Services layer, defines the basic behavior of objects, establishes mechanisms for their management, and provides the ability to use primitive data types, collections, and operating system services.
AppKit is dependent on Foundation, which is functionally located in the Core Services layer. If you look closely 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.
- Core Foundation. Many Foundation framework classes are based on equivalent opaque Core Foundation classes. This close connection makes the conversion between compatible types of Core Foundation and Foundation “free.” Core Foundation classes, in turn, use Darwin's BSD layer.
- Carbon core AppKit and Foundation use the Carbon Core framework to access some system services. For example, Carbon provides the Core File Manager, which Cocoa uses to work with various file systems.
- Core Graphics. Cocoa uses Core Graphics for most graphics-related tasks.
- Launch Services. The NSWorkspace class provides the core capabilities of Launch Services. Cocoa also uses the capabilities of Launch Services to associate icons with applications and documents.
Apple has carefully designed Cocoa so that some of its programming interfaces provide access to the basic functions that applications typically need. But if you need some features that are not
available through Cocoa interfaces, or if you need finer control over what is happening in the application, you can directly use the main frameworks (a striking example is Core Graphics, by calling functions you can get more powerful ones graphics controls).
And how is Cocoa friends with iOS?
The iOS app execution layer is called Cocoa Touch. Although the iOS infrastructure on which Cocoa Touch runs is similar to the one on which Cocoa runs on Mac OS X, there are some significant differences (Figure 2).

Figure 2. That's how iOS is friends.
As a rule, the system libraries and iOS frameworks that UIKit uses are a subset of the libraries and frameworks of Mac OS X. However, due to the nature of the devices supported by iOS,
there are some frameworks which are specific to iOS.
The following is a summary of some of the frameworks for each layer:
- Core OS This layer contains the kernel, file system, network infrastructure, security, power management, and a number of device drivers. It, among other things, contains the libSystem library, which supports the POSIX / BSD 4.4 / C99 API specifications and includes systems at the API level for many services.
- Core Services Provides basic services, such as string manipulation, collection and network management, contact management, settings. They also make it possible to use the hardware features of the device (GPS, compass, accelerometer and gyroscope).
- Examples of the framework for this layer are Core Location, Core Motion, and System Configuration.
- This layer includes both Foundation and Core Foundation, which provide some types of data, such as strings and collections.
- Media Provides the Cocoa Touch layer with access to multimedia features. Includes Core Graphics, Core Text, OpenGLES,
- Core Animation, AVFoundation, Core Audio, and video playback services.
- Cocoa Touch. Engaged in direct application support. Contains components such as Game Kit, Map Kit, and iAd.
Cocoa on iOS, just like Cocoa on Mac OS X, gives applications access to basic functionality. And if you need something more than what the Cocoa API provides, you can also directly use lower-level methods.
Source - Cocoa Fundamentals Guide