Cocoa and Cocoa Touch are application development environments built from Objective-C. Cocoa is based on Cocoa API (for the Mac operating system) and includes a wide assortment of frameworks which makes application development much easier. Cocoa Touch is the version used for mobile devices and it focuses on touch interaction.
Read the following:
As you read your lesson, pay close attention to the key terms and phrases listed throughout the lesson. These terms and concepts are important to your understanding of the information provided in the lesson.
A framework is a set of libraries. The code accesses the capabilities of a framework through the application programming interface (API). The library is dynamically shared, so multiple apps can access the framework code and resources at the same time. There are three basic frameworks used in almost every project. When a template is created in single view, the Foundation, UIKit, and Core Graphics frameworks are automatically added.
The Foundation framework takes much of the Core Foundation Framework (C Framework) by wrapping it in Objective-C. The Foundation framework determines how all of the components interact with each other and includes:
UIKit framework is required for interface creation and interaction. Some of the included features are:
The Core Graphics Framework consists of the interfaces for drawing 2D images and includes support for:
A list of iOS Frameworks can be viewed at the iPhone Development Wiki website. This reference provides the version that a framework was first available in to help in planning the design for a particular iOS device. The description provides a brief explanation of what each framework contains. Links for each framework display in-depth, language reference information.
There are four layers that make up an application and Figure 1 shows the iOS architecture. The fundamental services and technologies are part of the lower layers. The upper layers build upon the lower layers and provide more pre-built items such as the frameworks and API's.
The Cocoa Touch layer is where most of the work occurs. This layer has all of the touch capabilities that make touch possible on the device. The Cocoa Touch layer includes the following:
The Media layer contains graphics, audio and video technologies and includes the following:
The Core Services layer contains fundamental system services used by all applications and includes the following:
The Core OS layer is probably the least worked with layer. It is mostly used by higher level frameworks, so a programmer would rarely work with this layer directly. It includes the following:
Design Patterns are not code. Understanding design patterns helps a programmer use frameworks more effectively and write apps that are usable and easier to change.
Model-View-Controller (MVC): Objects in an app are assigned a role: model, view, or controller. Models handle the data; views display the interface and make up the content; and controllers handle the interaction between views and models. Notice that views and models do not directly interact with each other; controllers serve as the middle man for model and view communications.
Delegation: A simple pattern that has one object, the delegating object, acting with another object, the delegate. One class has another class carry out specific actions on its behalf. The delegating object keeps a reference to the delegate and will send a message to the delegate when necessary. Recall that protocols are a set of methods that do a certain job or perform a certain role. Protocols are often delegates for the class that uses them. Implementing a delegate chain system in Objective-C provides an example of how delegation works.
Target-Action: An object sends a message to a second object when an event occurs. For example, say a user interacts with an object which triggers an event. Target-Action is the connection between the object and the action that occurs. Outlets allow a controller to access properties of an interface object. Actions allow a specific interface object to access a specific method.
Notifications: The Notification Center is part of the Foundation framework. Its function is to broadcast a message to any object that is setup to watch for messages.
Notifications can be used to notify multiple objects of an event, but a notification does not return a value. Take, for example, an app that is going into the background. A notification will be sent; anything listening for that notification hears it and then runs whatever code has been set up specifically when that event occurs.
Key-Value Observing: One object sees the property of another object. This is used to synchronize changes between related objects. A controller observes properties of models. Views observe properties of models through controllers. This means that an object is notified of changes to specified properties of other objects.
This course is only scratching the surface. Due to the depth of this topic, it is important to become familiar with several references. Start out by reviewing the resources at the iOS Developer Library.
This lesson introduced Cocoa Touch and the frameworks used for developing apps that run on iOS devices. This lesson also looked at design patterns which guide a programmer in developing apps that are usable and easier to change.
This work is created by the National Information Security and Geospatial Technologies Consortium (NISGTC), and except where otherwise noted, is licensed under the Creative Commons Attribution 3.0 Unported License.
Authoring Organization: Collin College
Written by: Original Author, Elizabeth Pannell; Edited Version, Susan Sands
Copyright © National Information Security, Geospatial Technologies Consortium (NISGTC)
Development was funded by the Department of Labor (DOL) Trade Adjustment Assistance Community College and Career Training (TAACCCT) Grant No. TC-22525-11-60-A-48; The National Information Security, Geospatial Technologies Consortium (NISGTC) is an entity of Collin College of Texas, Bellevue College of Washington, Bunker Hill Community College of Massachusetts, Del Mar College of Texas, Moraine Valley Community College of Illinois, Rio Salado College of Arizona, and Salt Lake Community College of Utah.
This workforce solution was funded by a grant awarded by the U.S. Department of Labor's Employment and Training Administration. The solution was created by the grantee and does not necessarily reflect the official position of the U.S. Department of Labor. The Department of Labor makes no guarantees, warranties or assurances of any kind, express or implied, with respect to such information, including any information on linked sites, and including, but not limited to accuracy of the information or its completeness, timeliness, usefulness, adequacy, continued availability or ownership.