2. Agenda
Basics of iOS
Introduction to iOS
What is iOS
Architecture
Design Patterns
Cocoa Touch Framework
What is Cocoa Touch Framework
Complete Assortment of Frameworks
iOS Application Design
MVC
Core Application Objects
Application Life Cycle
3. Introduction to iOS
What is iOS?
iOS (known as iPhone OS before June 2010) is Apple's
mobile operating system. Originally developed for the iPhone, it has
since been extended to support other Apple, Inc. devices such as the
iPod touch, iPad and Apple TV. Apple, Inc. does not license iOS for
installation on third-party hardware.
4. Architecture
Core OS:
This level contains the kernel, the file system, networking infrastructure,
security, power management, and a number of device drivers. It also has the
libSystem library, which supports the POSIX/BSD 4.4/C99 API specifications and
includes system-level APIs for many services.
5. Architecture
Core Services:
The frameworks in this layer provide core services, such as string
manipulation, collection management, networking, URL utilities,
contact management, and preferences. They also provide services
based on hardware features of a device, such as the GPS, compass,
accelerometer, and gyroscope. Examples of frameworks in this layer
are Core Location, Core Motion, and system configuration.
6. Architecture
Media:
The frameworks and services in this layer depend on the Core Services layer and
provide graphical and multimedia services to the Cocoa Touch layer. They include
Core Graphics, Core Text, OpenGL ES, Core Animation, AVFoundation, Core Audio, and
video playback.
7. Architecture
Cocoa Touch:
The frameworks in this layer directly support applications based in iOS. They include
frameworks such as Game Kit, Map Kit, and iAd.The Cocoa Touch layer and the Core
Services layer each has an Objective-C framework that is especially important for
developing applications for iOS. These are the core Cocoa frameworks in iOS:
8. Architecture
UIKit:
This framework provides the objects an application displays in
its user interface and defines the structure for application
behavior, including event handling and drawing.
Foundation:
This framework defines the basic behavior of objects,
establishes mechanisms for their management, and provides
objects for primitive data types, collections, and operating-
system services. Foundation is essentially an object-oriented
version of the Core Foundation framework.
9. Design Patterns
Model-View-Controller
Is a way of dividing your code into independent functional areas. The model
portion defines your application’s underlying data engine and is responsible for
maintaining the integrity of that data. The view portion defines the user
interface for your application and has no explicit knowledge of the origin of
the data displayed in that interface. The controller portion acts as a bridge
between the model and view and coordinates the passing of data between
them.
Block objects
Block objects are a convenient way to encapsulate code and local stack
variables in a form that can be executed later. Support for block objects is
available in iOS 4 and later, where blocks often act as callbacks for
asynchronous tasks.
Delegation
The delegation design pattern is a way of modifying complex objects without
sub classing them. Instead of sub classing, you use the complex object as is
and put any custom code for modifying the behavior of that object inside a
separate object, which is referred to as the delegate object. At predefined
times, the complex object then calls the methods of the delegate object to
give it a chance to run its custom code.
10. Design Patterns
Managed memory model
The Objective-C language uses a reference-counted scheme for
determining when to release objects from memory. When an object is first
created, it is given a reference count of 1. Other objects can then use the
retain, release, or autorelease methods of the object to increase or
decrease that reference count appropriately. When an object’s reference
count reaches 0, the Objective-C runtime calls the object’s cleanup
routines and then deallocates it.
Threads and concurrent programming
All versions of iOS support the creation of operation objects and
secondary threads. In iOS 4 and later, applications can also use Grand
Central Dispatch (GCD) to execute tasks concurrently.
11. Cocoa Touch Framework
Cocoa touch is Apple's name for the collection of frameworks, APIs, and
accompanying runtimes that make up the development layer of iPhone OS. By
developing with the Cocoa touch frameworks you will be writing applications the
same way that iPhone OS itself is written, with controlled access to the
operating system.
Much of Cocoa Touch is implemented in Objective-C, an object-oriented
language that is compiled to run at incredible speed, yet employs a truly
dynamic runtime making it uniquely flexible. Because Objective-C is a superset
of C, it is easy to mix C and even C++ into your Cocoa Touch applications.
As your application runs, the Objective-C runtime instantiates objects based on
executing logic — not just in ways defined during compilation. For example, a
running Objective-C application can load an interface (a nib file created by
Interface Builder), connect the Cocoa objects in the interface to your
application code, then run the correct method once the UI button is pressed. No
recompiling is necessary.
12. Complete Assortment of Frameworks
In addition to UIKit, the Cocoa Touch collection of frameworks
includes everything needed to create world-class iOS apps,
They are,
3D graphics
Professional audio
Networking
Camera API
GPS
System Level Access API
13. Complete Assortment of Frameworks
Core Animation
Use Core Animation to create rich user experiences from an
easy programming model based on compositing
independent layers of graphics
Core Audio
Core Audio is the professional-grade technology for
playing, processing and recording audio, making it easy
to add powerful audio features to your application
Core Data
Core Data provides an object-oriented data
management solution that is easy to use and
understand, yet is built to handle the data model
needs of any application, large or small.
14. Complete Assortment of Frameworks
Features List: Frameworks by Category
Below is a small sampling of the available frameworks included in
Cocoa Touch:
Audio and Video
•Core Audio
•OpenAL
•Media Library
•AV Foundation
Graphics and
Animation
•Core Animation
•OpenGL ES
•Quartz 2D
User
Applications
•Address Book
•Core Location
•Map Kit
•Store Kit
Data Management
•Core Data
•SQLite
Networking and Internet
•Bonjour
•WebKit
•BSD Sockets
15. Features Of Cocoa Application
Basic application framework
User-interface objects
Drawing and imaging
System interaction
Performance
Internationalization
Text
Preferences
Networking
Printing
Undo management
Multimedia
Data exchange
16. MVC Architecture
A design pattern in which the model (any data in your program), the
view (what the user sees), and the controller (a layer that handles all
interaction between the view and model) are separated in such a manner that
modifying either the view or model component of your program has no effect
on one another.
17. MVC Architecture - Model
A model represents an application’s data and contains the logic for accessing
and manipulating that data.
Any data that is part of the persistent state of the application should reside in
the model objects.
The services that a model exposes must be generic enough to support a variety
of clients.
Model services are accessed by the controller for either querying or effecting a
change in the model state.
18. MVC Architecture - View
• The view is not dependent on the application logic. It remains same if there is
any modification in the business logic the view is responsible for rendering the
state of the model.
• The presentation semantics are encapsulated within the view, therefore model
data can be adapted for several different kinds of clients.
• The view modifies itself when a change in the model is communicated to the
view. A view forwards user input to the controller.
19. MVC Architecture - Controller
Controller accepts and intercepts user requests and controls the business
objects to fulfill these requests.
An application has one controller for related functionality.
Controller can also be depends on the type of clients.
22. Core Application Objects
From the time our application is launched by the user, to the time it exits, the
UIKit framework manages most of the application’s core behavior. For example,
an iOS application receives events continuously from the system and must
respond to those events. Receiving the events is the job of the UIApplication
object, but responding to the events is the responsibility of your custom code.
Key Objects in iOS:
UIApplication object
Application delegate object
Data model objects
View controller objects
UIWindow Object
View, Control, and layer objects
24. Application Life Cycle
The application life cycle constitutes the sequence of events that
occurs between the launch and termination of your application. In iOS, the user
launches your application by tapping its icon on the Home screen. Shortly after
the tap occurs, the system displays some transitional graphics and proceeds to
launch your application by calling its main function. From this point on, the
bulk of the initialization work is handed over to UIKit, which loads the
application’s main bib file and readies the event loop.
30. Responding To App Termination
Although applications are generally moved to the background and
suspended, if any of the following conditions are true, your application is
terminated and purged from memory instead of being moved to the background:
The application is linked against a version of iOS earlier than 4.0.
Application is deployed on a device running a version of iOS earlier than 4.0
The current device does not support multitasking
The application includes the UIApplicationExitsOnSuspend key in its Info.plist
file
Hinweis der Redaktion
What follows is a short list of how Cocoa adds value to an application with only a little (and sometimes no) effort on your part:
Basic application framework—Cocoa provides the infrastructure for event-driven behavior and for management of applications, windows, and (in the case of Mac OS X) workspaces. In most cases, you won’t have to handle events directly or send any drawing commands to a rendering library.
User-interface objects—Cocoa offers a rich collection of ready-made objects for your application’s user interface. Most of these objects are available in the library of Interface Builder, a development application for creating user interfaces; you simply drag an object from the library onto the surface of your interface, configure its attributes, and connect it to other objects. (And, of course, you can always instantiate, configure, and connect these objects programmatically.)
Here is a sampling of Cocoa user-interface objects:
Windows
Text fields
Image views
Date pickers
Sheets and dialogs
Segmented controls
Table views
Progress indicators
Buttons
Sliders
Radio buttons (Mac OS X)
Color wells (Mac OS X)
Drawers (Mac OS X)
Page controls (iOS)
Navigation bars (iOS)
Switch controls (iOS)
Cocoa in Mac OS X also features technologies that support user interfaces, including those that promote accessibility, perform validation, and facilitate the connections between objects in the user interface and custom objects.
Drawing and imaging—Cocoa enables efficient drawing of custom views with a framework for locking graphical focus and marking views (or portions of views) as “dirty.” Cocoa includes programmatic tools for drawing Bezier paths, performing affine transforms, compositing images, generating PDF content, and (in Mac OS X) creating various representations of images.
System interaction—In Mac OS X, Cocoa gives your application ways to interact with (and use the services of) the file system, the workspace, and other applications. In iOS, Cocoa lets you pass URLs to applications to have them handle the referenced resource (for example, email or websites); it also provides support for managing user interactions with files in the local system and for scheduling local notifications.
Performance—To enhance the performance of your application, Cocoa provides programmatic support for concurrency, multithreading, lazy loading of resources, memory management, and run-loop manipulation.
Internationalization—Cocoa provides a rich architecture for internationalizing applications, making it possible for you to support localized resources such as text, images, and even user interfaces. The Cocoa approach is based on users’ lists of preferred languages and puts localized resources in bundles of the application. Based on the settings it finds, Cocoa automatically selects the localized resource that best matches the user’s preferences. It also provides tools and programmatic interfaces for generating and accessing localized strings. Moreover, text manipulation in Cocoa is based on Unicode by default, and is thus an asset for internationalization.
Text—In Mac OS X, Cocoa provides a sophisticated text system that allows you to do things with text ranging from the simple (for example, displaying a text view with editable text) to the more complex, such as controlling kerning and ligatures, spell checking, regular expressions, and embedding images in text. Although Cocoa in iOS has no native text system (it uses WebKit for string drawing) and its text capabilities are more limited, it still includes support for spellchecking, regular expressions, and interacting with the text input system.
Preferences—The user defaults system is based on a systemwide database in which you can store global and application-specific preferences. The procedure for specifying application preferences is different for Mac OS X and iOS.
Networking—Cocoa also offers programmatic interfaces for communicating with servers using standard Internet protocols, communicating via sockets, and taking advantage of Bonjour, which lets your application publish and discover services on an IP network.
In Mac OS X, Cocoa includes a distributed objects architecture that allows one Cocoa process to communicate with another process on the same computer or on a different one. In iOS, Cocoa supports the capability for servers to push notifications to devices for applications registered to received such notifications.
Printing—Cocoa on both platforms supports printing. Their printing architecture lets you print images, documents, and other application content along a range of control and sophistication. At the simplest level, you can print the contents of any view or print an image or PDF document with just a little code. At a more complicated level, you can define the content and format of printed content, control how a print job is performed, and do pagination. In Mac OS X, you can add an accessory view to the Print dialog.
Undo management—You can register user actions that occur with an undo manager, and it will take care of undoing them (and redoing them) when users choose the appropriate menu items. The manager maintains undo and redo operations on separate stacks.
Multimedia—Both platforms programmatically support video and audio. In Mac OS X, Cocoa offers support for QuickTime video.
Data exchange—Cocoa simplifies the exchange of data within an application and between applications using the copy-paste model. In Mac OS X, Cocoa also supports drag-and-drop models and the sharing of application capabilities through the Services menu.