A Brief Guide To The iOS App Development

22
A BRIEF GUIDE TO       THE       iOS       APP DEVELOPMENT

Transcript of A Brief Guide To The iOS App Development

Page 1: A Brief Guide To The iOS App Development

A BRIEF GUIDE TO

      THE      iOS       APP DEVELOPMENT

Page 2: A Brief Guide To The iOS App Development

-------. Contents

Introduction

Chapter 1: iOS App Architecture­­­­­ App Behaviors­­­­­ The App Bundle­­­­­­The App Life Cycle­­­­­­The Structure Of An App­­­­­­The Role Of Object In An iOS App

Chapter 2: Background Execution­­­­­ Downloading Content In The Background­­­­­ To Implement Long­Running Tasks­­­­­­To Declare The App's Supported Background Tasks

Chapter 3: Strategies (For Handling App State Transitions)­­­­­ The Launch Cycle

Chapter 4: Strategies (For Implementing Specific App Feature)­­­­­­ How To Implement Specific Types Of Feature In Your App­­­­­­ To Support Multiple Versions Of iOS­­­­­­ Protecting Your Visual Appearance Of App Across Launches­­­­­­ The Preservation & Restoration Process­­­­­­ Tips For Developing & VoIP App

Chapter 5: Inter-App Communication­­­­­­ To Support Air Drop

Chapter 6: Performance Tips­­­­­­ Reducing The App's Power Consumption

Page 3: A Brief Guide To The iOS App Development

Will This ebook Right For You?Maybe! See the content below in order to determine if your level matches the content that you are about toread. This ebook is not a beginner's guide to creating iOS apps, but this is for developers who want to polishtheir apps. With the help of this ebook, you'll get to know­ how the app interacts with the system & what itmust do to make those interactions happen smoothly. 

­­­­­­­­­­.Prefatory

The  content   is   for   those  who  are  new  to   the   subject.  The   introductory   level   of   the   topic   is   our  ebookUnderstanding iOS App Development. It embraces step­by­step instructions on how to get started with iOSgame programming.

­­­­­­­­­­­­­­­­­­­­­­­.Intermediate

Some   intermediate   content   for   those   developers   who   are   familiar   with   the   subject   but   have   the   basicknowledge regarding the concept. 

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­.Advanced

Advanced sections for those who want to be an expert in the niche of iOS app development. After reading it,you'll feel ready not only to execute tactics & strategies. Nonetheless, teach everyone how to succeed in theniche.

Page 4: A Brief Guide To The iOS App Development

­­­­­­­­­­­.INTRODUCTION

The marketing of iPhone app development is thriving! Thanks to the efforts of numerous creative companies& individual involved in iPhone app development.

iPhone Apps are really hot! These are not the merely one of the biggest categories on the App store, but this issomething that one of the best­selling categories among all. 

iPhone OS is a mobile operating system that is developed by Apple Inc. It was first released in the year of2007, including iPhone & iPod. 

The iOS SDK has embraced from 1.0 to 9.0.

iOS 9.x (iOS 9.0 Beta 1 & iOS 9.0 Beta 2) is the latest SDK and officially supported version in Xcode 7.0 Beta 1 &Beta 2.

Having a wide range of Apple documentation & finding out which methods & libraries can be used by that istypically based on the deployment target. The Power of iOS embraces the following features, including Maps,Siri, Facebook & Twitter, Powerful APIs, Safari, etc. 

Numerous people use iPhone & iPad and it creates the opportunity for iPhone app developers that can createboth free & paid applications in order to make money. 

For newbies to iOS, Apple has designed an “App Store” where the user can buy useful apps for their iOSdevices. 

 

Page 5: A Brief Guide To The iOS App Development

1. iOS APP ARCHITECTURE

The applications need to work with iOS in order to ensure that they deliver a great user­experience. Merely agood user­experience & a good applications' design, it offers a lot of other factors. Undoubtedly, people wouldlove like to responsive, fast, simple & user­friendly applications from iOS apps. 

Also, apps need to support all the latest iOS devices. However, these tasks may seem daunting at first, thisebook helps you to make it happen very easily.

This ebook highlights the core behaviours that make the app work amazingly well! If you are ready to takeyour ideas & turn them into an application then you need to completely understand the interaction between­the system & your app.

Applications.Support Key Features

The system believes that each app must have some specific resources & configuration data. 

For   instance,   an   application   icon   &   info   regarding   the   applications'   capabilities.  Xcode  renders   someinformation regarding every new project. The main thing is that­ you must have resource files & make surethe info of the project of yours is correct before submitting the app! 

Follow Well­Defined Execution Paths

During the life of an app, it can shift between foreground & background of execution. Plus, it can terminate &relaunch. Or, it can go to sleep for the time being. 

At every time, when it shifts to a new state, then the expectations change for the app. 

Foreground App: It can do almost anything.

Background App: It can do as little as possible.

Nevertheless, in order to change your app's behaviour, you use the state transitions. 

Must Run Expeditiously In A Multitasking Environment

For users: the life of the battery is pivotal as in its performance, responsiveness & last but not the least greatuser experience. Regarding the app, it is pivotal to the minimal usage of battery that ensures the user that canrun your app entire day without having recharge the device. 

The Communication Between Apps Must Follow­ The Specific Paths

iOS   Apps   run   in   a   sandbox   as   well   as   it   has   limited   interaction   between   other   apps.   If   you   want   tocommunicate with other apps on the system, then there are some specific ways.

'Performance Tuning' is Pivotal 

The task is performed by apps have a power cost associated with it. If the app drains the user's battery thatcreate a negative user experience. Hence, be aware with the cost of diverse operations & take advantage ofpower­saving measures offered by the system.   

Page 6: A Brief Guide To The iOS App Development

App Behaviours

Each new Xcode project comes designed to run right away in Simulator or on a device. Being able to run theapp on the device, that does not mean that your app is ready to run on 'App Store'. 

Each & every app requires some magnitude of customization in order to ensure a great experience to the user.Does customization range from in order to provide an icon for your app to crafting architecture­level decisionregarding­ How the application presents & uses the information? 

We are going to explain the behaviours that all apps are expected to handle & you should adapt these thingsat the early stage of the planning process. 

The Required Set of Resources...

Every application that you create has some set of resources & meta data. So that it can be displayed easily oniOS devices. 

The Information property­list file

For your app, the Info.plist file contains metadata that the system uses to interact with your app. Xcodecreates this file automatically that is based on your project's settings & configuration. If you want to modifythe contents of that file directly, then you can do so from the information tab of your project.

One or more icons

The icon that displays the app icon on the home screen of  the user's  device.  The system may use otherversions of your icon in the Settings App when displaying the results of the search. 

One or more launch Images

When an app launches,   the system displays temporary images until   the app is  able to represent  its  userinterface. And it provides the immediate feedback that the app is launching & it will be ready soon.  

The Declaration: Required capabilities of the app  

Each app must declare the hardware capabilities or features that are required to run. The app store uses theinformation in order to determine either a user can run your app on specific device or not. 

The App BundleWhen you build an iOS app, then Xcode packages it as a bundle. A bundle is a directory in the file system thatgroups related resources together in one place. 

iOS bundle contains the app executable files & supporting resource files that include app icons, image files &localized content. 

The App Life Cycle

Applications play a sophisticated interplay between the system framework & custom code. 

The System Framework­ it provides the basic infrastructure that the apps need to run. It also provides the

Page 7: A Brief Guide To The iOS App Development

code that is required to customize the infrastructure. Finally, it provides the look & feel to the app that exactlyyou want to.

The iOS Framework relies on the design patterns as in MVC (Mobile View Controller) & delegation in theirimplementation. 

In order to create the successful app, it is pivotal to understand­ the design patterns. 

The Structure Of An AppThe functions UIApplicationMain   handles the procedure by creating the core objects of the app and forstart­up, this function sets up so many key objects. 

The heart of every iOS app is the UIApplication object that works to facilitate the interaction between thesystem & other objects in the app.

The iOS apps use MVC (Model­view­controller) architecture. This kind of pattern separates the app'sdata & business logic from the visual presentation of the data. The architecture is pivotal in order to create anapp that can run on 'diverse devices' with 'different screen sizes'.

Figure­1

THE ROLE OF OBJECTS IN An iOS App

UIApplication Object:It manages the event loop & high­level app behaviors. Also, it reports key app transitions & some specialevents. Use the UIApplication object as is­that is, without subclassing.

App Delegate Object: This is the heart of the custom­code. The object tasks with UIApplication object in order to handle appinitialization, state transitions & many high­level app events.  App Delegate object uses to set up

Page 8: A Brief Guide To The iOS App Development

the application's initial data structures.  

Documents & Data Model Objects: The  Data Model Objects store the content of the app. Apps can also be used documents objects inorder to  manage few or  all  data model objects.  The documents  objects  are not  needed but offering  theconvenient method to group data, which belongs to the single file or file package. 

View Controller Objects:It manages the presentation of the content of your app. A view controller manages a single view & thecollection of   sub­views.  For  all  view controller  objects,   the  UIViewController  class   is   the  base class.Providing default functionality for loading views, presenting & rotating them in response to device rotations. 

UIWindow Object: It coordinates the presentation of one or more views on screen. Usually, most apps have only one window thatrepresents content on the main screen. But, apps may have an additional window for content that is displayedon an external display.   

View, Control & Layer ObjectsViews & controls render the visual presentation of app's content. A view is an object that draws the content ina designed rectangular area. The  Control objects  are specialized type of view responsible to eventswithin the area. 

The UIKit Framework provides standard views for presenting numerous different types of content. 

Page 9: A Brief Guide To The iOS App Development

2. BACKGROUND EXECUTIONIf the user isn't actively using your app, then the system moves it to the background state. For numerous apps,the background is merely a brief stop to the app that is being suspended. Do you know that suspended appsare the way in order to improve the battery life that allows the system to devote pivotal system resources tothe new foreground apps that have drawn the user's attention?

There are a number of apps that can move to the extended state so easily, but there are some legal reasons forapps to continue running in the background. The techniques offered by iOS fall into three categories:

• Apps that needs to run in the background in order to specific types of tasks that can declare theirsupport for one or more execution roles.

• Apps that start a short task in the foreground that can ask for time to finish the task­ when the appsmove to the background.

• Apps which initiate downloads in the foreground. Thereby, allowing the apps to be suspended orterminated whilst the download continues.

Downloading Content In The BackgroundIn order to download the file, the apps should be an NSURLSession object to start the downloads. Sothat the system can take complete control of the download process when the app is suspended. The processfor creating a configuration object which supports the background downloads as follows:

• Create the configuration object using the backgroundsessionconfigurationwithidentifiermethod of NSURLSessionConfiguration.

• Set the value for configuration object

• Configure any other properties of the configuration objects

• Use the Configuration object to create  NSURLSession object

To Implement Long-Running Tasks

Tasks require more execution time to implement, then you must request specific permissions to run them inthe background. In iOS, there are some specific apps that are allowed to run in the background:

Applications­

– That play audible content to the user whilst in the background. For instance, music player app.– That record audio content whilst in the background.– That keep users informed at all times. For instance, Navigation app– That support voice over internet Protocol (VoIP)– That require to download & process the new content regularly– That receive regular updates from external accessories

Page 10: A Brief Guide To The iOS App Development

To Declare The App's Supported BackgroundTasks

In Xcode5, you do declare the background modes that your app supports from the capabilities tab of projectsettings. Here are the background modes for apps:

• Audio & Airplay• Location Updates• Voice Over IP• Newsstand Download• External accessory Communication• Background Fetch• Remote Notifications• Uses Bluetooth LE Accessories• Acts as a Bluetooth LE Accessories

To Track The User's Locations

Numerous ways to track the user's locations in the background that do not actually require your app to runcontinuously in the background:

• Background Location Services• Foreground­only Location Services• The Significant change Location Service

To Play & Record Background Audio

You must be familiar with the app that plays & records the background audio continuously that can register toperform these tasks in the background. You can enable audio support from the Background modes section ofthe capabilities tab in your Xcode project. The apps that play audio content in the background that must playaudible content & not silence.  

Here are the typical examples of background audio apps:

• Music Player App• Audio Recording App• App that supports audio as well as video playback over AirPlay• VoIP Apps

In   the   case,   when  UIBackgroundModes  key   contains   the   audio   value,   then   the   media   frameworksautomatically prevent the corresponding app from being suspended when we talk about the background. 

As long as it plays audio or video content, then the app continuously contains in the background, and theprocess for using the frameworks is unchanged. 

To Implement A VoIP App

Allowing the user to make phone calls using an internet connection rather than the cellular service of thedevice. But an app needs to maintain a persistent network connection to its associated service so that it canreceive incoming calls & other relevant data.   

In order to configure a VoIP app, then you must do the following:

• Enable support for VoIPfrom the background modes section of the capabilities tab in Xcode project.

Page 11: A Brief Guide To The iOS App Development

• For VoIP usage, configure of the app's sockets.• Call   the  setKeepAliveTimeout:   handler  method   to   install   a   handler   to   be   executed

periodically.• Configure audio session to handle transitions to & from active use.

To Fetch Small Amounts Of Content Opportunistically 

The Application that needs to check for new content periodically that can ask the system to wake up early thatthey can fetch operation for the content.

In order to support the mode, you have to enable Background fetch option from the Background fetch optionof the “Capabilities Tab” in your Xcode project. You can enable this support by this method also, includingUIBackgroundModes key with the fetched value in the app's  Info.plist file. In order to enable thismode is not guaranteed that the system will give the app to perform background fetches anytime. 

When the favourable opportunities arise, the system wakes up or launches the app into the background & callthe  app delegate's  application:  performFetchWithCompletionHandler:  method.  Use   this  method   inorder to check for the new content and initiate the download operation if the content is available. 

To Use Push­Notifications To Initiate The Download

In case, if the server sends the push­notifications to the user's device when new content is available for yourapp, then you can ask the system to run the app in the background. 

In order to support this Background mode:

• Enable the Remote Notification Options from the Background modes section of the Capabilities tab inthe Xcode project. 

• Alternative Method: You can also enable the support, including the UIBackgroundModes key withthe remote­notification value in the app's Info.plist file.

• For a push notification to activate the download operation, the notification's payload must embracecontent­available key with its value set to 1.

• While downloading any content, it is recommended that use the  NSURLSession  class to initiate.Hence, manage your downloads. 

To Download Newsstand Content In The Background

• The Newsstand App downloads new magazine or newspaper  issues  that  can register   in  order  toperform these downloads in the background. 

• To   enable   this   support   by   including   the  UIBackgroundModes  key   with   the  newsstand­content value in the app's Info.plist file.

• To Communicate With An External AccessoryTo enable this support by including the  UIBackgroundModes key with the external­accessory valuein the app's Info.plist file.

To Communicate With The Bluetooth AccessoryTo enable this support by including the  UIBackgroundModes key with the Bluetooth­central valuein the app's Info.plist file.

Page 12: A Brief Guide To The iOS App Development

To Understand When, The App Gets Launched Into The Background

The App, which supports the background execution may be relaunched by the system in order to handle theupcoming events. In case, when the app is terminated for any reason other than the user force quitting it. 

The system launches the app when there are one of the following events happen:

• For Location Apps• For Bluetooth Apps • For Audio Apps• For Background Download Apps

How To Opt Out Of Background Execution

If   you   do   not   want   to   run   your   app   in   the   background   at   all,   then   you   can   do   it   by   adding   theUIApplicationExitsOnSuspend key to your app's Info.plist file.

Page 13: A Brief Guide To The iOS App Development

3. STRATEGIES (FOR HANDLING APPSTATE TRANSITIONS)

For every run­time state of an app, the system has myriad expectations during the app is in the state. 

When it comes to “State Transitions”, then the system notifies the app object that in turn notifies the appdelegate. Use state transition methods of the  UIApplicationDelegate protocol in order to detect thesestate changes & respond accordingly. 

The Launch CycleWhen the app launches, it moves from “the not running state” to “active or background” state. 

The system creates the process & main thread of your app. Plus, it calls your app's main function on the mainthread. The default main function comes from Xcode project over the UIKit Framework that does not most ofthe work in initializing your app & preparing it to run. 

Figure:1 Launching An App Into The Foreground

Page 14: A Brief Guide To The iOS App Development

Figure­2 Launching An App Into The Background

Page 15: A Brief Guide To The iOS App Development

4. STRATEGIES (FOR IMPLEMENTINGSPECIFIC APP FEATURES)

Diverse apps have different requirements, but there is one thing that is common among all apps that are“behavior”. 

How To Implement Specific Types Of Features In Your App-

Privacy Strategies

To protect the user's privacy is quite an important task more than anything in order to design an app. Theprivacy protection includes protecting the user's data, personal info & user's identity. 

The system frameworks provide privacy controls for managing data e.g. contacts. But your app should takesteps in order to protect the data that you use locally. 

To Protect Data Using On­Disk Encryption

The data protection uses built­in hardware  in order to store files  in an encrypted format on­disk and todecrypt them on demand. 

As long as user's device is locked, the protected files are unapproachable. The user must unlock the device byentering the appropriate passcode before an app can access one of protected files. Data protection is availableon iOS devices & it is subjected to the following requirements:

• The file system (user's device) must support data protection. • The user must have an active passcode lock set for the device.

Protecting The File: To Protect a file, add this attribute either NSData class or NSFileManager class. 

To Write New Files: Writing new files, use writeToFile:options:error: method of NSData with anappropriate protection value.

For Existing File: Use the setAttributes:ofItemAtPath:error: method of NSFileManager to setor change the value of NSFileProtection key.  

To Identify the Unique Users of Your App

It is pivotal that you should identify the unique users of your app. iOS providers identifiers can help you to dothat. In case, if need a higher level of securities, then you might need to do more work on your own. Forinstance, an app that provides financial services that would likely to ready the user for login credentials inorder to ensure that the user is authorized to access a specific amount. 

Note: Identifying the user, always be transparent regarding what you think to do with any kind of informationthat you obtain. Moreover, it is not acceptable to identify the users  so you can stalk them surreptitiously. 

Have a look to the following scenarios that may need you to identify the user, along with the solutions forHow to implement them?

Page 16: A Brief Guide To The iOS App Development

Linking A User To The Specific Amount On Your Server:It includes a login screen, which requires the user to enter their account information securely. Bear in mindthat always protect the user's information by storing it an encrypted form. 

Differentiating The Instances Of Your App Running On Diverse Devices: Use the identifierForVendor property of the UIDevice class to obtain an ID that differentiate the useron one device from users to other.  The technique does not allow you to identify specific users. A single usercan have myriad devices with a different id value. 

Identifying The User For The Purposes Of Advertising:Use the advertisingIdentifier property of the ASIdentifierManager class to obtain an ID for theuser.

Due to the reason is that­ users are allowed to run apps on all their iOS devices. Apple does not render a wayto identify the same user on myriad devices.   

To Support Multiple Versions of iOS

The App, which supports the latest versions of iOS plus one or earlier versions must use runtime checks inorder to prevent the use of newer APIs that is an older version of iOS. 

The Runtime Checks­ It prevents your app from crashing when it tries to use a feature which is not availableon the recent operating system. 

Protecting Your Visual Appearance of App across launches It does not matter if the app supports background execution, and it can not run forever! At that point, thesystem might need to terminate your app in order to free up the memory for the current foreground app. 

Moreover, the user should never be interested if an app is already running or was terminated. Quitting an appshould just seem like a temporarily interruption. When, for example, you are a user, you return to the app,the app should always return the user to the last point of use. So that, if you come back to the app, then theapp should always return to the last point, where you left the task. 

And this kind of behavior renders a better experience for the user & with the restoration support that is builtinto UIKit that is relatively easier to achieve.  

The State Prevention System­ In UIKit provides the state prevention system provides a simple but flexibleinfrastructure for preserving & restoring the state of the app's views & view controllers. Well, there are threeplaces where you should think about state prevention in your apps:

• The delegate object of the app that manages the app's top­level state.• The view controller objects of the app that manage the overall state for the user interface of app.• The custom views of app that might have some customized data that needs to be preserved.

UIKit allows you to opt for which parts of the user interface that you want to preserve. In case, if you already have custom code in order to handle state preservation. You can use that code & migrate parts to the UIKitstate preservation system as needed. To Enable State Preservation & Restoration In Your App

Page 17: A Brief Guide To The iOS App Development

The two­ State Preservation & Restoration both are not automatic features. Apps indicate their support for thefeature in order to implement the following methods in their app delegate:

application: shouldSaveApplicationState: 

application: shouldRestoreApplicationState: 

The Preservation & Restoration Process

Both processes are opt­in features & work with the help of your app. You app does identify the objects thatshould be preserved & UIKit does the work preserving & restoring these objects at appropriate times. Due tothe reason that­ UIKit handles so much of the process. It also helps to understand what it does behind thescenes so that you know how the customized code fits the overall scheme. 

UIKit preserves your app's state at appropriate times, in case when your app moves from the foreground to thebackground. Whilst the restoration process, UIKit uses the preserved data to reconstitute the interface but thecreation of actual objects is handled by the code. Due to your app may load the objects from a storyboard fileautomatically, only when the code knows which object need to be created.

Whilst Preservation, The App Is Responsible For:

• To tell the UIKit that it supports state preservation• To tell the UIKit that view controllers & views should be preserved• To encode the relevant data for any preserved objects

Whilst Restoration, The App Is Responsible For: 

• To tell the UIKit that it supports state restoration• To provide the objects that are requested by UIKit• To decode the state of your preserved objects & using it to return the object to its previous state

Tips for Developing a VoIP App

VoIP  is Voice Over Internet Protocol that allows the user to make a call over internet connection instead ofthe cellular services. This app needs to maintain persistent network connection to its connected service so thatit can receive incoming calls & other relevant data. Instead of keep VoIP apps awake all the time, then thesystem allows  them to be suspended & providing  facilities   in  order  to  monitor   their   sockets.   In   case,   ifincoming traffic is detected, then the system wakes up the VoIP app and returns control of its sockets to it. Forimplementing the VoIP app, there are numerous requirements out there:

• Enable the voice over IP background mode for your app. • For VoIP usage, configure one of the app's sockets.• Before moving to the background, call the setKeepAliveTimeout:handler: method in order to

install a handler to be executed periodically. • Configure your audio session to handle transitions to & from active use.• Ensuring a better user experience on iPhone, use  the Core Telephony Framework  to adjust your

behavior in relation to cell­based phone calls.• Ensuring good performance for your VoIP app, use the System Configuration Framework to detect the

network changes & allow your app to sleep as much as possible.

Page 18: A Brief Guide To The iOS App Development

5.Inter-App Communication

Apps can communicate indirectly with other apps on the device!

You can use AirDrop to share files & data with other apps. In addition, you can also define custom URLscheme. So that the apps can send information to your with the help of URLs.

To Support AirDrop

With the help of AirDrop, you can share images, documents & another sort of data with nearby devices. Onthe  other  hand,  AirDrop  takes  advantage  of  peer­to­peer  (P2P)  networking  to   find  out  close  devices  &connect to them. 

To Send Data & Other Documents To Another AppUsing AirDrop, you can send data & other documents, use UIActivityViewController object to displayan activity sheet from your user interface. 

You can specify images, strings, URLs & other types of data as well as you can also pass custom objects thatadopt the UIActivityItemSource protocol.  

To Receive Files & Data Sent To Your AppIn order to receive files & data sent to your app using AirDrop, you can do the following:

• In Xcode, declare support for the document types that your app is capable of opening.• Implement   the   application:  OpenURL:sourceApplication:annotation:  method.   Use   this

method to receive the data, which was sent by another app.• And be prepared to look for files in your app's Documents/Index directory & move them out of that

directory as needed. 

To Use URL Schemes To Communicate With AppsThe next is URL schemes, it lets you communicate with apps through a protocol that you specify. In order tocommunicate with an app which implements such a scheme that you must create an fittingly formatted URLand ask the system to open it.  

To Send A URL To Another AppIf you want to send data to an app that implements a custom URL scheme. Create an appropriately formattedURL & call the OpenURL: method of the app object. 

The  OpenURL: method launches the app with registered scheme & passes the URL to it. At the point, controlpasses to the new app. 

To Implement Custom URL SchemesIf the app can receive specially formatted URLs, then you should register the corresponding URL schemes withthe system. Apps use customized URL schemes to vend services to other apps. 

For instance, the Maps App supports URLs for displaying map locations.

To Register Custom URL Scheme

Page 19: A Brief Guide To The iOS App Development

Include   the  CFBundleURLTypes  key   in   your   app's  Info.plist  file.   The    CFBundleURLTypes  keycontains an array of dictionaries & each of that defines a URL scheme the app support. 

CFBundleURLName­ A string contains the abstract name of the URL scheme. Ensuring uniqueness & it isrecommended that you specify a reverse DNY­style of identifier. For instance com.acme.myscheme. 

CFBundleURLSchemes­  An   array   of   string   containing   the   URL   scheme   names.   For   instance  HTTP,mailto, tel, & SMS.

To Handle URL RequestsThe app which have its own custom URL scheme must be able to handle URLs passed to it. All URLs passed tothe app delegate (either at launch time or app is running or in the background). Handling incoming URLs, thedelegate should implement the following:

• Use the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods to retrieve the information about the URL 

• Use the application:openURL:sourceApplication:annotation: method to open file.

Page 20: A Brief Guide To The iOS App Development

6. Performance TipsEvery step during the development of app, consider the implementation of the design choices on the entireperformance of the app. 

There are two extremely pivotal considerations for iOS apps i.e. 

1. Power Usage2. Memory Consumption

In addition, there are several considerations apart from the above two. 

Reducing The App's Power Consumption

“Power consumption” is always an issue. The power management system in iOS preserves power by shuttingdown any hardware features that are not recently being used. You can easily improve battery life in order tooptimize the use of the following features:

• The Disk• The CPU• The Core Location Framework• Bluetooth, Wi­fi, & the Baseband (EDGE, 3G) radios• The Accelerometers

The objective of optimizations should be to the most work that you can in the best effective & possible way.You must always optimize the algorithm of your apps using instruments. However, even the most optimizedalgorithm can  still  have  a  negative   impact  on   the  battery   life  of  device.  Thus,  you   should   follow  theseguidelines whilst writing your code:

• Always avoid doing work that requires “polling”. The term “polling” prevents the CPU from going tosleep. Rather than polling, use the NSRunLoop or NSTimer classes to schedule work as needed. 

• Don't draw to the screen faster than is needed. Whilst drawing is costly operation when it comes topower. And also don't rely on hardware in order to throttle the frame rates. 

• If you use UIAccelerometer class to receive regular accelerometer events.

• Also, avoid accessing the disk too frequently.

It is pivotal that­ the more data you transmit to the network, the more power must be used to run the radios.However, to access the network, this is the most pivotal power­intensive operation that you can perform. Youcan also minimize the timings by following these guidelines:

• Connect to the external network servers only when needed and do not poll those servers.

• When you connect to the network, then the smallest amount of data needed to the job. You can avoidthat to use the compact data formats. Do not include excess content that is simply ignored.

• Connect to the network to the using the WiFi radios whenever possible. WiFi generally uses lesspower. This is proffered over cellular radios. 

• If you use Core Location framework in order to gather information, disable location updates as soonas you can. Set the distance filter & accuracy levels to suitable values. 

Page 21: A Brief Guide To The iOS App Development

The instrument apps include many instruments in order to gather power related information. You can usethese instruments in order to gather general information regarding­ power consumption as well as gatherspecific measurements for hardware including WiFi & Bluetooth Radios, Display, GPS Receiver & CPU. 

Use Memory Expeditiously

Usually, the apps are encouraged in order to usage as little as possible, therefore, system may keep more appsin memory & dedicate more memory to foreground apps. 

The amount of free memory available to the system is directly proportional to the relative performance ofyour app. If there the free memory is less that means the system the system is more likely to have troublefulfilling memory requests. 

Ensuring that there is always enough memory available, that you should minimize your app's memory usage& to be responsive when the system asks you to free space in memory. 

Tips for Efficient Networking

One of the most­power intensive options­ to implement code to receive or transmit data across the network.In order to minimize the amount of time spent transmitting or receiving data that helps to improve yourbattery life. 

When writing the network­related code, you should consider the following tips:

• Avoid using “chatty protocols”.• For protocols, define your data formats to be as compact as possible.

 

To Use WiFiUsing the WiFi radios, you must notify the systems, including  UIRequiresPersistentWiFi key in theapp's Info.plist file. 

Improving the File ManagementGenerally, file operations are relatively slow & involve writing to the flash drive that has a limited lifespan.Avoid writing cache files to the disk. When your app is quit & you need to write state information that can beused to put the app back into the same state when it is next launched.

Page 22: A Brief Guide To The iOS App Development

Build Awesome iOS AppsStart Creating Your Own iOS App