tutorial: (SPLASH 2010) iPhone Application Development

ACM Conference on Object Oriented Programming, Languages and Applications
(is now part of ACM Conference on Systems, Programming, Languages and Applications: Software for Humanity)
Reno, NV. October 2010
Tutorial 13.

0. Abstract

Apple’s mobile handheld devices have been a huge success; beginning with the launching of the iPhone in 2007 and that has been maintained until present days with the launching of the iPad in 2010. There are now more than 85,000 apps available for the more than 50 million iPhone and iPod touch customers worldwide and over 125,000 developers in Apple’s iPhone Developer Program.  That is why iPhone is a new and widely extended platform to develop object-oriented applications.iPhone platform involves several and amazing technologies that makes programming it a cool activity for experienced programmers willing to know the goodness of a mobile device, and a great option for students or novices to learn programming. Both of them will find the power of the iPhone libraries and development tools amazing to quickly start building powerful iPhone apps. We will be using Xcode under Mac OS X as our IDE, and Objective-C and iPhone API as our programming tools to create iPhone applications (from basic to medium level), which finally can be loaded into the iPhone device. We’ll start with the classical “Hello World” and continue to develop applications using graphical user interfaces, handling multi-touch and motion detection, communication interfaces, and different media.

1. Introduction

iPhone is an amazing device that incorporates several technologies (phone, multi-touch interface, several sensors, video camera, video and audio player, high resolution and small screen, several ways of wireless communication, among others). This device has been received several awards such as the best device in 2007 (Times Magazine), it was the big winner in the 2008 British Technology Awards. It also claimed the award for Gadget of the Year, won the Best Mobile Technology, Most Stylish Technology, and Technological Innovation awards in 2009.iPhone has captive the interest of different types of users and created a new emerging market in various environments. Today, thousands of programmers want to provide applications to the iPhone and take advantages of the amazing features of the device.

2. Tutorial Presentation History

This tutorial has been presented at the last two OOPSLAs (2008 and 2009). Beside that, this material has been presented in others forums such as Tecnologico de Monterrey (in Mexico) and Arizona State University (in USA). This has helped to improve the content, activities and time management.The material  (slides and examples) that we had been using during all these years are available on web, and can be consulted at iphone.javiergs.com.

3. Tutorial Objectives

Through this tutorial, the attendee will:

  • Learn about iPhone software architecture.
  • Learn about iPhone Development tools and Objective-C programming language.
  • Learn about the iPhone Application Framework.
  • Learn about the User Interface Design and key practices for iPhone Applications.
  • Learn how to take advantage of the capabilities for measure Location, Acceleration, Orientation and Multi-touching into the apps.
  • See an overview about the construction of rich Graphics and Media apps.

4. Tutorial Content

This is a three (3) hours tutorial, through them, after a brief introduction about iPhone software architecture and iPhone SDK developing tools, our intention is that participants work on hands-on exercises. Attendees will develop applications and try them into an iPhone simulator or into an iPhone physical device. Through the tutorial, lecture and exercises would be alternated. In order to take the most advantage of this tutorial it is desirable that the attendees work on their own laptops and that install the iPhone SDK in advance.

4.1. Kick Off

Even though the iPhone’s size is small, its power and potential are not. As we get ready to create applications for this cool platform, it is good to have in mind its characteristics and limitations so that we can maximize its benefits, thus we start the tutorial talking about:

  • iPhone physical specifications.
  • Detailed description of hardware features.
  • Multi-threading characteristics (differences between iOS 4 and previous versions).
  • Graphical User Interface guideline design.
  • The screen size.
  • The five seconds rule.
  • File and data management.
  • Memory management and lack of garbage collection.

4.2 Getting Started with the Development Tools

Once we have everything installed and ready, we can start working with the development tools. In order to develop an iPhone application, we will need to use the following development tools:

  • Xcode. Apple’s Integrated Development Environment (IDE). This includes all of the tools we need to create and manage our iPhone projects and source files, build our code into an executable, and run and debug our code either on the iPhone simulator or on a device.
  • Interface Builder. It is the tool we use to assemble our application’s user interface visually. Using Interface Builder, we assemble our application’s window by dragging and dropping pre-configured components onto it. The components include standard system controls such as switches, text fields, and buttons, and also custom views to represent the views our application provides. After we have placed the components on the window’s surface, we can position them by dragging them around, configure their attributes using the inspector, and establish the relationships between those objects and our code.
  • iPhone simulator. When we build our application in Xcode, we have a choice of building it for iPhone simulator or for a device. The simulator provides a local environment for testing our applications to make sure they behave essentially the way we want. After we are satisfied with our application’s basic behavior, we can tell Xcode to build it and run it on an iPhone or iPod touch connected to our computer.

These tools are free, however they do not allow us to upload our applications to our iPhone (or iPod Touch, or iPad) or distribute our software in Apples’ iPhone App Store. In order to do this, we have to sign up the Apple Developers Program.

4.3 Reviewing iOS Framework and Architecture

The iOS comprises the operating system and technologies that we use to run applications natively on iPhone and iPod touch devices and iOS. Although it shares a common heritage and many underlying technologies with Mac OS X, iOS was designed to meet the needs of a mobile environment. Existing Mac OS X developers will find many familiar technologies, but they will also find technologies that are available only on iOS supported hardware. We will present here the iOS framework architecture and explore the four layers of this architecture: Cocoa Touch, Media, Core Services, and Core OS.

4.4 Learning About Objective-C

Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the standard ANSI C language. The use of objects and object-oriented constructs is fundamental to the design of iPhone applications, and understanding how they interact is critical to creating our applications, so it helps if attendees have previous experience with object-oriented languages. The goal of this part of the tutorial is to quickly review the syntax of Objective-C, and be sure that the creation of classes, methods, protocols, and delegates is clear using this language.

4.5 Creating an iPhone Application

After reviewing all the concepts mentioned above and learn about all the tools we have, we will start describing a step-by-step procedure to create a simple “Hello World” application. Later on we will extend on top of this application. We are going to:

  • Add labels, buttons, and work with event process.
  • Get familiarized and get used to work with Xcode and Interface Builder.
  • Talk about Software Design patterns and how they are fundamental in Phone application development, in particular we will need to review Model View Controller (MVC), Singleton and Delegate patterns.
  • Learn and make relationship with IBAction and IBOutlet keywords. And understand how these are the basics for connecting our code with our graphical user interfaces.
  • Work with the View-based template and the Navigation-based template for projects in Xcode

4.6 Process Multi-Touch Events

One of the coolest features of the iPhone, is its ability to handle touch events. The multi-touch interface of the iOS provides an application with the ability to recognize and react to different events triggered when multiple fingers touch the iPhone screen. When a finger touches the screen a touch event is created. When a finger moves across the screen, new touch events are created in order to track the new position of the finger. When the finger looses its contact with the screen, the system creates another touch event to capture that. The system tracks all these events and reacts. Every time that a touch event is created, it includes information regarding the current state of each finger in contact with the screen (either touching the screen or when it looses contact with the screen). This allows the system to keep track of all the finger actions. Working with this characteristic demands from the developer know and work with the UIResponder class and its methods.

4.7 Sensors

Mainly we are going to spend time reviewing Accelerometer and Core Location Framework:

  • Accelerometer. iPhone has a three axes accelerometer to detect motion in any direction. They can detect the physical orientation of the device in a 3D space. We can then apply this orientation and its changes as inputs to our application. In order to do that, UIViewController class provides the infrastructure needed to rotate our interface and adjust the position of views automatically in response to orientation changes. And UIAccelerometer object in UIKit allows us to access to the raw accelerometer data directly. We can also use the data to detect the device’s orientation or to detect other types of instantaneous motion, such as the user shaking the device back and forth.
  • Core Location Framework. The Core Location framework uses the available hardware to determine the user’s position and heading. We will use the classes and protocols in this framework to configure and schedule the delivery of location and heading events.

At this point we will be reviewing and using the CLLocationManager and CLLocationManagerDelegate classes in our applications.

4.8 Graphics and Media

At this point is for sure that all attendees will have a good knowledge about apps development. So, it will be a good point to move forward and take a look into computer graphics. This will be a really basic introduction; this tutorial is not about how to create videogames or applications like this, however we will review some basis, so if someone is interested on more, they will know where to search. We will talk about:

  • OpenGL ES. Open Graphics Library (OpenGL) is a cross-platform C-based interface used for visualizing 2D and 3D data. OpenGL functions send graphics commands to the underlying hardware, where they are then rendered. Because this underlying hardware is dedicated to processing graphics commands, OpenGL drawing is typically very fast. OpenGL for Embedded Systems (OpenGL ES) is a version of OpenGL designed for mobile devices and takes advantage of modern graphics hardware.
  • Quartz. It is a two-dimensional drawing engine available for iOS application development and to all Mac OS X application environments outside of the kernel. Quartz provides low-level lightweight 2D rendering with unmatched output fidelity regardless of display or printing device. Quartz is resolution- and device-independent; we do not need to think about the final destination when we use the Quartz application programming interface (API) for drawing. The Quartz 2D API is easy to use and provides access to powerful features such as transparency layers, path-based drawing, off-screen rendering, advanced color management, anti-aliased and rendering.

Quartz API is part of the Core Graphics framework that we will review in this part of the tutorial.

4.9 Data Manipulation and More Examples

When working on iPhone programming, keep in mind that we can have different types of data. Remember that we are working in an object-oriented environment so our data will be related and organized in objects that have attributes and methods. We will play with different examples that involve data manipulation, from arrays of objects to examples on the use of the Core Data framework which provides solutions to common tasks associated with object life-cycle including persistence. One of the ways to achieve persistence with Core Data is based upon SQLite. For this part of the tutorial it will be, useful—although not essential—to have at least a superficial understanding of the SQL language. This is the last topic in our agenda, so sometimes the time is not enough to go through it, but we will try at lest to show examples and give references to motivate attendees to continue by themselves on their learning.

5. Audience

This tutorial is open to Researchers, Practitioners, and Educators. But we are assuming that attendees have programming skills but not necessarily known about any specific programming language or development tools. The tutorial starts with a brief description of the language, the tools, the architecture of the apps and after that we show, through different examples, how to build apps that take advantage of all different qualities of this mobile device.


These are my slides for the tutorial, any comment is more than welcome.



Gonzalez-Sanchez, J. and Chavez-Echeagaray, M.E. (2010). iPhone Application Development. Proceedings of the 25th International Conference on Systems, Programming, Languages and Applications: Software for Humanity (SPLASH). Reno, Nevada, USA. October 2010. ACM, pp 321-322. ISBN: 978-1-4503-0240-1. doi: 10.1145/1869542.1869629.