ios basics

30
iOS Basics JPA Solutions

Upload: muthu-sabarinathan

Post on 22-Jan-2018

383 views

Category:

Education


0 download

TRANSCRIPT

iOS Basics

JPA Solutions

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

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.

ArchitectureCore 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.

ArchitectureCore 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.

ArchitectureMedia:

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.

ArchitectureCocoa 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:

ArchitectureUIKit:

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.

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.

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.

Cocoa Touch FrameworkCocoa 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.

Complete Assortment of FrameworksIn 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

Complete Assortment of Frameworks

Core AnimationUse Core Animation to create rich user experiences from an easy programming model based on compositing independent layers of graphics

Core AudioCore Audio is the professional-grade technology for playing, processing and recording audio, making it easy to add powerful audio features to your application

Core DataCore 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.

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

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

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.

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.

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.

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.

MVC Architecture Workflow

MVC - Communication

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

Core Application Objects

Application Life CycleThe 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.

Application Life Cycle

Launching the Application

Moving to the Background

Responding to Interruptions

Resuming Foreground Execution

Responding To App TerminationAlthough 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