You are on page 1of 42

iOS

M2M COMMUNICATIONS

iOS is the operating system at the heart of iPhone, iPod touch, and iPad devices. The iOS platform was built using the knowledge that went into the creation of Mac OS X, and many of the tools and technologies used for development on the platform have their roots in Mac OS X as well. Despite its similarities to Mac OS X, iOS does not require experience developing Mac OS X applications. The iOS Software Development Kit (SDK) provides everything you need to get started creating iOS applications.

Introduction Overview of Apple iOS


1. 2. 3. 4. The Anatomy of an iOS The iOS Architecture and Frameworks An Overview of the iPhone OS Architecture iPhone Development Frameworks

M2M COMMUNICATIONS

Introduction
iOS is Apples mobile operating system. Developed originally for iPhone it has since been shipped on the iPodTouch and iPad as well. iOS is derived from Mac OS X,with which it shares the Darwin foundation and is therefore a Unix-like operating system by nature. In iOS,there are four abstraction layers: the core OS layer, the core services layer, the Media layer and the Cocoa touch layer. The OS was roughly 500 megabytes of devices storage. M2M COMMUNICATIONS
WIRELESS APPLICATIONS

The Smartphone Platform


With the iOS being the first to the marketplace it sets the configuration of the Smartphone Platform
3G/4G connectivity WiFi connectivity Bluetooth connectivity accelerometer w/compass ambient light sensor proximity sensor GPS gyroscope

Mobile Handset OSes Globally


Key mobile OSes: Symbian OS BlackBerry OS Google Android Apple iOS Windows Phone 7 (formerly Windows Mobile) Others include: HP Palm webOS Samsung bada

Mobile Handsets in US
3.20% 8.00% 31.20% 24.70% Google RIM Apple Microsoft

Palm
30.40%

Mobile Handset OSes


Symbian (^n) OS (ARM only) Open-source (Nokia) Multitasking Programming: C++, Java ME, Python, Qt/HTML5 BlackBerry OS (ARM) Proprietary (RIM) Multitasking Many enterprise features Programming: Java ME, Adobe AIR (tablet) iPhone OS (ARM only) Proprietary (Apple) Multitasking Multi-touch interface Programming: Objective-C

Windows Phone 7 (ARM only) Proprietary (Microsoft) No multitasking Programming: Silverlight/XNA, C#.NET/VB.NET Android (ARM, x86, ) Open-source Multitasking Programming: Java (Apache Harmony), scripts Other OS features Most require app code signing Many support Adobe Flash/AIR, multitasking ARM is predominant ISA

iOS
Originally developed for the iPhone, it has since been extended to support other Apple devices s Apple's App Store contains more than 300,000 iOS applications iOS 4.3 was released to the public on March 9, 2011, 2 days before the iPad 2. In addition to earlier features, the public release of iOS 4.3 includes many new features such as a Nitro JavaScript engine in Safari, making Safari run up to twice as fast. iOS 5.0 and its features were announced on June 6 at the WWDC 2011 keynote address. The expected release date is believed to be sometime in the third quarter of 2011. I OS 5 will introduce the iCloud service and the Notification Center, as well as improvements to native apps such as Camera.

IOS

Overview of Apple iOS iOS comprises the operating system and technologies that use to run applications natively on devices,such as iPad, iPhone and iPad touch. The iOS SDK contains the tools and interfaces needed to develop, install, run, and test native applications. Native applications are built using the iOS system frameworks and Objective-C language and run directly on iOS. Unlike web applications, native applications are installed physically on a device and are therefore always available to the user, even when the device is in Airplane mode. They reside next to other system applications and both the application and any user data is synced to the users computer through iTunes. The Xcode tools provide the basic editing,compilation, and debugging environment for the code. Xcode also provides the launching point for testing applications on an iOS device and in iPhone Simulator-a platform that mimics the basics iOS environment but runs on local Machintosh computer.

M2M COMMUNICATIONS

APPLE iOS
Company/developer Apple inc.

Programming in
OS family

C,C++,Objective-C
Mac OS X/UNIX like

Supported Platforms
Kernel Type Default user interface Licence Official website

ARM(iPhone,iPodTouch and iPad)


Hybrid(Darwin) Cocoa Touch(MultiTouch,GUI) Proprietary EULA except for open source components iPhone Developer program

M2M COMMUNICATIONS WIRELESS APPLICATIONS

Native vs Web Apps

Native vs Web Apps


Native Apps: Written in a programming language for a targeted operating system Apple iOS Devices: iOS SDK, using Objective-C Android Devices: Android SDK, using Java Have access to all features of the hardware Camera, GPS, Accelerometer, Microphone, etc. Are distributed via the respective app marketplace iTunes App Store, Android Marketplace iOS apps are subjected to rigorous testing/acceptance process; Android apps are submitted to the Marketplace with little oversight Development fees: Apple: SDK is free (registration required), $99 to submit apps to App Store Android: SDK is free, $25 to submit apps to Android Marketplace

Native vs Web Apps


Web Apps:
Web-based applications written with traditional web programming languages
HTML/CSS, Javascript, PHP/.NET/JSP

Have limited access to device hardware (depends on platform) Can be used cross-platform (some restrictions apply) Most are intended to be used when the device is online; some have capabilities for offline use Most platforms have some Semblance of a web app store, but the stores and their contents vary widely
No centralized marketplace for all platforms

The iOS Architecture


The iOS architecture is similar to the basic architecture found in Mac OS X. At the highest level, iOS acts as an intermediary between the underlying hardware and the applications that appear on the screen, as shown in Figure The applications created rarely talk to the underlying hardware directly. Instead, applications communicate with the hardware through a set of welldefined system interfaces that protect application from hardware changes. This abstraction makes it easy to write applications that work consistently on devices with different hardware capabilities.

iOS Technology Layers The Kernel in iOS is based on a variant of the same basic Mach kernel that is found in Mac OS X On the top of this kernel are layers of services that are used to implement applications on the platform The implementation of iOS technologies can be viewed as a set of layers, which are shown in Figure . At the lower layers of the system are the fundamental services and technologies on which all applications rely;higher-level layers contain more sophisticated services and technologies.

Core OS and Core Services layers contain the fundamental interfaces for iOS Media layer contains the fundamental technologies used to support 2D and 3D Drawing,audio and video In Cocoa Touch layer most of the technologies use objective-C

M2M COMMUNICATIONS WIRELESS APPLICATIONS

iOS Technology layers

Touch Screen

Broadcom BCM5974 Controller

Multi-touch No stylus or non-conductive gloves

Cocoa Touch layer

The Cocoa Touch layer sits at the top of the iOS stack and contains the frameworks that are most commonly used by iapplication developers. Cocoa Touch is primarily written in Objective-C, is based on the standard Mac OS X Cocoa API and has been extended and modified to meet the needs of the iOS This layer defines the basic application infrastructure and support for key technologies such as multitasking, touch-based input, push notifications, and many high-level system services. When designing your applications, you should investigate the technologies in this layer first to see if they meet your needs.

Contains the key frameworks for building iOS applications.


UIKit framework is a vast and feature rich Objective-C based programming interface.Some of the key features of UIKit are as follows:
User interface creation and management (text fields, buttons, labels, colors, fonts etc) Application lifecycle management Application event handling (e.g. touch screen user interaction) Cut, copy, and paste functionality Web and text content presentation and management Data handling Inter-application integration Push notification in conjunction with Push Notification Service Accessibility Accelerometer, battery, proximity sensor, camera and photo library interaction.

Map Kit Framework (MapKit.framework)


Provides you with a programming interface that enables you to build map based capabilities into your own applications. This allows to, amongst other things, display scrollable maps for any location, display the map corresponding to the current geographical location of the device and annotate the map in a variety of ways.

Push Notification Service


allows applications to notify users of an event even when the application is not currently running on the device. Since the introduction of this service it has most commonly been used by news based applications. This alert is typically accompanied by an audio alert and vibration of the device

Message UI framework
provides everything you need to allow users to compose and send email messages from within your application.

Address Book UI Framework (AddressUI.framework)


key function of device as a communications device and digital assistant an entire framework is dedicated to the integration of the address book data into your own applications. The primary purpose of the framework is to enable you to access, display, edit and enter contact information from the iOS address book from within your own application.

Game Kit framework


provides peer-to-peer connectivity and voice communication between multiple devices and users allowing those running the same app to interact. When this feature was first introduced it was anticipated by Apple that it would primarily be used in multi-player games (hence the choice of name) but the possible applications for this feature clearly extend far beyond games development.

The iOS Media Layer


The Media layer is to Contains the graphics, audio, and video technologies geared toward creating the best multimedia experience available on a mobile device. The technologies in this layer were designed to make it easy to build applications that look and sound great. comprises a number of frameworks that can be utilized when developing iOS apps.

1 Core Graphics Framework (CoreGraphics.framework) lightweight 2D rendering engine.


Features include PDF document creation and presentation, vector based drawing, transparent layers, path based drawing, anti-aliased rendering, color manipulation and management, image rendering and gradients.

2 Quartz Core Framework (QuartzCore.framework) provide animation capabilities on the iPhone.


It provides the foundation for the majority of the visual effects and animation used by the UIKit framework and provides an Objective-C based programming interface for creation of specialized animation

3 OpenGL ES framework (OpenGLES.framework) standard for high performance 2D and 3D graphics drawing has been OpenGL.
for Embedded Systems (ES) is a light weight version of the full OpenGL specification designed specifically for smaller devices such as the iPhone.

4 iPhone Audio Support


capable of supporting many audio formats (AAC, Apple Lossless (ALAC), Alaw, IMA/ADPCM, Linear PCM, -law, DVI/Intel IMA ADPCM, Microsoft GSM 6.10 and AES3-2003 )

5 AV Foundation framework designed to allow the playback, recording and management of audio content. 6 Core Audio Frameworks (CoreAudio.framework, AudioToolbox.framework and AudioUnit.framework) supported audio types, playback and recording of audio files and streams and also provide access to the devices built-in audio processing units. 7 Open Audio Library (OpenAL) cross platform technology used to provide high-quality, 3D audio effects (also referred to as positional audio) 8 Media Player framework (MediaPlayer.framework) able to play video in .mov, .mp4, .m4v, and .3gp formats at a variety of compression standards, resolutions and frame rates.

The Core Services layer contains the fundamental system services that all applications use. Even if you do notuse these services directly, many parts of the system are built on top of them.
iCloud storage lets your application write user documents and data to a central location and access those items from all of a users computers and iOS devices. Making a users documents ubiquitous using iCloud means that a user can view or edit those documents from any device without having to sync or transfer files explicitly. Storing documents in a users iCloud account also provides a layer of safety for that user. Even if a user loses a device, the documents on that device are not lost if they are in iCloud storage.

There are two ways that applications can take advantage of iCloud storage, each of which has a different intended usage: iCloud document storageUse this feature to store user documents and data in the users iCloud account. iCloud key-value data storageUse this feature to share small amounts of data among instances of your application.

1.

Address Book framework (AddressBook.framework)


Provides programmatic access to the iPhone Address Book contact database allowing applications to retrieve and modify contact entries.

2.

Core Data Framework (CoreData.framework)

This framework is provided to ease the creation of data modeling and storage in Model-View-Controller (MVC) based applications. Significantly reduces the amount of code that needs to be written to perform common tasks when working with structured data in an application.
C-based Framework that provides basic functionality such as data types, string manipulation, raw block data management, URL manipulation, threads and run loops, date and times, basic XML manipulation and port and socket communication. Additional XML capabilities beyond those included with this framework are provided via the libXML2 library. most of the capabilities of the Core Foundation framework are also available with Objective-C wrappers via the Foundation Framework.

3.

Core Foundation Framework (CoreFoundation.framework)

4. 5.

Foundation Framework (Foundation.framework)


standard Objective-C framework that will be familiar to those that have programmed in Objective-C on other platforms

Core Location Framework (CoreLocation.framework)


Allows to obtain the current geographical location of the device (latitude and longitude) and compass readings from with your own applications. The method used by the device to provide coordinates will depend on the data available at the time the information is requested and the hardware support provided by the particular iPhone model on which the app is running (GPS and compass are only featured on recent models). This will either be based on GPS readings, WiFi network data or cell tower triangulation (or some combination of the three).

6.

Store Kit Framework (StoreKit.framework)


Facilitate commerce transactions between your application and the Apple App Store Allows for a lightweight, SQL based database to be created and manipulated from within your iPhone application.

7.

SQLite library

The Core OS Layer is the bottom layer of the iPhone OS stack and sits directly on top of the device hardware. The layer provides a variety of services including low level networking, access to external accessories and the usual fundamental operating system services such as memory management, file system handling and threads.

APPLE iOS 4 Review


Whats new
Home screen wallpapers Folder organizations of the home screen icons Multitasking and the fast switching Google/Wikipedia search in spotlight Bluetooth keyboard pairing support SMS character counter SMS search Email threading 5x digital zoom in still camera Video call support(only in iPhone 4 and only over wifi)

WIRELESS APPLICATIONS

Whats still missing


No flash support in web browser No true multitasking for all applications iOS 4 for iPhone 3G has limited new feature set Poor performance on iPhone 3G No quick toggles for Wi-fi, bluetooth or 3G No social networking integration No info widgets on lock screen or home screen SMS tones are still not customizable No mass mark emails as read No USB mass storage mode

M2M COMMUNICATIONS WIRELESS APPLICATIONS

Development: Mac OS X applications cannot be copied to and run on an iOS device The applications must be written and compiled specifically for iOS and ARM architecture The Safari web browser supports web applications as with other web browsers

M2M COMMUNICATIONS WIRELESS APPLICATIONS

THE iOS SDK


The iOS SDK comes with all of the interfaces, tools, and resources needed to develop iOS applications from Intelbased Macintosh computer. Apple delivers most of its system interfaces in special packages called frameworks. A framework is a directory that contains a dynamic shared library and the resources (such as header files, images, helper applications, and so on) needed to support that library. To use frameworks, you link them into your application project just as you would any other shared library. Linking them to your project gives you access to the features of the framework and also lets the development tools know where to find the header files and other framework resources.

The iOS SDK comes with all of the interfaces, tools, and resources needed to develop iOS applications. Apple delivers most of its system interfaces in special packages called frameworks. A framework is a directory that contains a dynamic shared library and the resources (such as header files, images, helper applications,and so on) needed to support that library. To use frameworks, you link them into your application project just as you would any other shared library. Linking them to your project gives you access to the features of the framework and also lets the development tools know where to find the header files and other framework resources. Although you can run applications in iOS Simulator, Xcode and Instruments also let you run and debug applications directly on an attached device. Simulator is ideal for building and testing applications quickly but is no substitute for testing on a real device. Development on an actual device requires signing up for Apples paid iOS Developer Program and configuring a device for development purposes.

In addition to frameworks, Apple also delivers some technologies in the form of standard shared libraries. Because iOS is based on UNIX, many of the technologies that form the lower-levels of the operating system are derived from open source technologies. The interfaces for these technologies are therefore available in the standard library and interface directories. Some other key components of the SDK include: Xcode Toolsthe tools that support iOS application development Xcodean integrated development environment that manages your application projects and lets you edit, compile, run, and debug your code. Xcode integrates with many other tools and is the main application you use during development. Instrumentsa runtime performance analysis and debugging tool. You can use Instruments to gather information about your applications runtime behavior and identify potential problems. iOS Simulatora Mac OS X application that simulates the iOS technology stack, allowing you to test iOS applications locally on your Intel-based Macintosh computer. iOS Developer Librarythe reference and conceptual documentation that teaches you all about iOS technologies and the application-development process.

Review Steps to Create an iPhone App


1. 2. 3. 4. 5. 6. 7. 8. 9. Create a project in Xcode. Create the user interface in Interface Builder (IB). Create the controller class in Xcode. Create the instance variables in Xcode. Create the Controller Object in IB. Connect Objects to Instance Variables in IB. Write source code in Xcode. Test in iPhone Simulator. Create app icon.

Effective iOS Memory Management Techniques.


iPhone Framework the developers can develop the application that uses the amount of available system memory (RAM) effectively and works well in low memory situations on device. Any application on iPhone device can use the amount of RAM available to it and if crosses the limit i.e. starts consuming more amount of memory and as a result of it if system become unstable, OS kills the application to avoid system crash.

Facts: 1. RAM Size: - iDevices 2G/3G have 128 MB of RAM, of which approx 35-40 MB is available to third party applications, rest of RAM is hardwired by OS for its own use. - Similarly iDevices 3G have 256 MB of RAM, out of which 4550 MB is available for third party applications. 2. Virtual Memory: iDevices framework do not have concept of virtual memory. 3. Garbage Collection: There is no automatic garbage collection mechanism in iPhone Framework. We need to take care of all the allocated objects and need to release/free them after use. Unlike JAVA garbage collection mechanism where the memory for allocated object is automatically reclaimed by system when it goes out of scope, in iPhone framework developer need to take care of releasing the memory for the object.

1.

Coding guidelines and ways for handling memory issues in iPhone Framework:

2.

Memory Warnings: These are the warnings/notifications generated by the OS/Framework and sent to the running application to notify that system is low on memory. On receiving these warnings application must try to release/free the unused memory like deleting cached images in RAM, freeing views and objects that are not on screen and those may be recreated later when user moves back on it, etc; to make the system stable and avoid being killed by OS. Avoid using autorelease objects and factory methods to create objects whenever possible: Because on iPhone OS an application executes in a more memoryconstrained environment, the use of autorelease pools is discouraged in methods or blocks of code (for example, loops) where an application creates many objects. Instead, you should explicitly release objects whenever possible. We must avoid using autorelease objects on main thread because the lifetime of these objects are same as lifetime of application.

3.

Create nested NSAutoReleasePools for heavy operations: Since iPhone Framework APIs heavily uses autoreleased objects, we must use nested autorelease pools like in a for loop while doing opertaions that uses more memory. 4. Reuse objects: We must make objects static whose lifetime is same as that of application and try to use them throughout the application, instead of creating same objects multiple time in the application. In case of UITableView we can reuse cells (please refer UITableView class for more details).

5. Create subview in viewWillAppear and free them in viewDidDisappear: Suppose we have image views as subviews to a view, so we can free these subviews when view is not on screen and again create them when view is going to appear on screen. 6. Avoid using UIImage imageNamed API: This API will increase performance when we are loding few small images, but if we are loading big images then this API is evil and using it may result in crash. This API cache the image in memory when image is loaded for first time and then gives the pointer to same location in memory when referenced again, but the following are issues using this API: - On low memory situation on device the cached images are freed thus our pointers may become dangling. - We do not have any control on freeing the image if we are done with it.

7.

Do not retain delegates permanently: Retain the delegate once assigned for giving the callbacks and release them after use. Retaining them permanently may result in memory leaks as the delegate is kept in memory even if it is not required. 8. Using Instrumentation: - Memory Leaks Tool: The Leaks instrument provides leak-detection capabilities. This instrument analyzes the inuse memory blocks of your application looking for blocks that are no longer referenced by your code. Unreferenced blocks are deemed leaks because they cannot be freed by your application and continue to occupy memory space until the user quits the application.

You might also like