iPhone and iPad SDK Programming Class

Programming the Apple iPhone and iPad devices using the IOS SDK can be challenging for beginners, but rewarding. This class covers a broad overview of iPhone and iPad programming, including a coverage of Objective-C, UIKit framework, and other frameworks needed for successful completion of iOS projects.

Lecture 11 - Hardware: CoreMotion, Accelerometer, Compass, GPS, Gyro

In this lecture we covered device hardware. Core Location and the Core Motion API were covered. Example_Location.zip demonstrates passing location data from Core Location to the google maps website as part of the query string.

Writing applications using HTML 5, css and Javascript were demonstrated.

HTMLDemo.zip is a project that demonstrates loading an html file locally from the application bundle. The local html file references a local javascript file, calling an annoying javascript popup.

Here are some interesting links related to authoring HTML apps:

genwi.com offers an HTML5 cms authoring service
HTML5 game tutorial from Six Revisions - very interesting coverage of HTML5 features
Phone Gap is an open source mobile dev platform
Bright Cove App cloud is another HTML5 app hosting service
Appcelerator is another HTML5 app hosting service with free trial

Homework 11: GPS

Write an application that displays the raw GPS data onto the screen. Optionally, use the MapKit API to display your location on a map.

Lecture 10 - Audio and Multimedia

In this lecture we covered the audio APIs.

See Audio_MixTest.zip (50 MB) as an example of AVAudioPlayer and AVAudioSession. The project file is a little large due to my simple drum groove wav file. See also Example_VibrateMe.zip for an example of playing a simple system audio sound.

Homework 10: Audio

Add an audio indicator to a previous homework assignment. For example, play a simple sound when a shape is touched in the Core Graphics assignment.

Lecture 9 - Network connections with sockets and GameKit

In this lecture we cover networking with sockets in the iOS environment, revisit NSURLConnection, and cover the GameKit classes.

Homework 9: GameKit and Sockets

Option 1: Write an application that communicates with another device over GameKit. When you type a message into a UITextField, that message should be displayed on the screen of the other device. In honor of Apple censorship, replace the letters of any objectionable word with symbols.

Option 2: Write an application that communicates through a socket to Node.js running on your mac. Anything that is typed into a UITextField should be displayed onto the screen of any other device connected to the same socket.

Lecture 8 - Concurrency and Multithreading - Keeping the UI Responsive During Background Processing

In this lecture, we look at methods of keeping the UI Responsive during background processing. Generally this will mean downloading content from the Internet on a background thread, and updating the screen when it is finished.

Techniques include: creating your own NSThread objects, using NSOperationQueue and NSOperation, using built-in delegate callback mechanisms of NSURLConnection, and Grand Central Dispatch. The 'Blocks' Objective-C language feature was discussed as an introduction to Grand Central Dispatch, which is a C-based API that leverages Blocks to place tasks into a queue for processing on other threads.

Example projects:
Example_Asynch.zip - very practical method of pulling content from the Internet using NSUrlConnection
DownloadMobyDick.zip - demonstrates AsyncString, my favorite way of pulling text from the Internet in the background
UCLA_GCD.zip - demo from class of refactoring blocking code using Grand Central Dispatch (GCD)
ClassDemo_AsyncWeb.zip - mostly functional attempt to show all techniques of background thread processsing such as NSOperation

This is a challenging and very important topic. Here are some resources to help:
  • iTunesU - Developing Apps for iOS(HD) - Paul Hegarty, Stanford, Lecture 13 - Blocks and Multithreading, 1 hour 6 minutes.
  • Concurrency Programming Guide, Apple
  • iTunesU - Advanced iPhone Development Spring 2010 - Dr. Brad Larson, Madison Area Technical College, Lecture 8 - Multithreading, 2.5 hours

Homework 8: Call a resource from the Internet and use that resource in your application. For example, call a large image and place it in a UIImageView or call an XML file and load it into a UITableView.

Start with a simple blocking call, then incorporate Grand Cental Dispatch to keep the UI functional during the download. Repeat the process using NSURLConnection and the delegate callback. Optionally incorporate at least one other technique such as NSOperationQueue to perform the same task.

Lecture 7 - Animation

In this lecture we scratched the surface of iOS Animation.

UIView animation is probably the most straightforward, with either [UIView beginAnimation] or the blocks feature. You might also check out the method on UIViewController to replace one view with another in an animated way.

An event can be called on a regular basis using [NSTimer scheduledTimer...] method. Inside the event handler, an internal variable can be updated which will affect the user interface. This is a common technique for games on the iPhone as well as other platforms, such as the PC or the PS3.

http://www.71squared.com/iphone-tutorials/ contains a really nice series of tutorials on iOS game programming that covers some of these topics. Apple has a document on animation that you might like as well.

Homework 7: iOS Animation
Extend the last homework assignment to make your shapes animate when touched. Possibilities include UIView animation, using a timer to fire an event, or adding a CAAnimation to the view's layer. You might experiment with all three.

Lecture 6 - Files, Custom View Drawing

In this lecture, we will continue covering working with files and will cover custom UIView drawing using Core Graphics.

Homework 6: Custom View Drawing
Create an ipad application that reads an XML file from the bundle and displays 5 custom views on your screen.

Each custom view should display either a circle or a square of a certain size, color and location on the screen depending upon the contents of the xml document. See RSSReader.zip for an example of reading an XML File.

Lecture 5 - UINavigationController & UITabController Wrapup, Storing Data

In this lecture, UITableNavigation Controllers were reviewed and UITabControllers were covered. The UITabController has many parallels to the UINavigationController - it acts as a wrapper around a collection of UIViewControllers, adding it's own UI on top of the views provided by the UIViewController's views.

Reading data from the Documents folder from the local drive was also introduced. See Example_Files.zip below for a sample.

Homework 5: UITabController
Create an iphone application using the view-based template. The application should have a UITabController at it's root, with three tabs: 1) UINavigationController holding a UITableView 2) UIWebView displaying a file from the documents directory 3) Scrolling UIImageView displaying an image that is larger than the screen.

Each tab should display a title and a png file. You might use the glyphish icons, use something from istockphoto.com, or make your own using Gimp.

See TabDemo201205.zip below for the example we created in class.

Lecture 4 - UITableView, UINavigationController

In this lecture, UITableView and the Delegation pattern were reviewed.

The UINavigationController class was introduced. This class manages a stack of UIViewController objects, and automatically provides the bar at the top of the screen, a back button, and the animation from one UIViewController's view to another UIViewController's view. It takes the 'title' property of the UIViewController and places that in the label in the center of the bar.

Homework 4: UINavigationController
Create an iphone application using the view-based template. Add a UINavigationController to the AppDelegate, initializing it with a UIViewController that holds a UITableView. When you tap a cell in the UITableView, it should push the next UIViewController onto the stack.

You should be able to recycle some work from homework 3 in this assignment.

Extra credit: use a property of the second UIViewController to gather context of what it should display from the UITableView.

See NavDemo.zip or TabDemo.zip below for some help.

Lecture 3 - More Foundation Classes, Delegation and UITableView

In this lecture, we covered more foundation classes, including the all-important NSArray, NSMutableArray, NSDictionary, and NSMutabledictionary classes.

We briefly discussed the delegation design pattern. Here is a link to the Apple docs that discuss delegation in Cocoa: Delegation.

To summarize delegation, an object delegates the responsibility to handle an event to some other object it has a reference to. Example: if you had an office assistant (delegate) and you hear the phone ring (event) you might ask your assistant to answer the phone, then forget about the call and move on with other tasks. If something important came up during the call, your assistant might let you know (notification). Events, delegates, and notifcations all work in the same manner in objective-C. You will often find that a user interface object becomes much more re-usable if it defines a delegate or a datasource by using a protocol.

In this video creating a reusable view controller with a UITableView is demonstrated.
http://git.certifiednetworks.com/videos/ios/UITableView.mp4 19.3MB 9:34

Homework 3: Table View
Create an iphone application using the view-based template. Place a UITableView onto the screen, and populate it with the contents of an array.

This was pretty late in getting posted, so you have an extra week to complete the assignment. We will review delegates and UITableViews again in class this week which will help you complete the assignment. Sorry about the delay.

Lecture 2 - More Objective-C, View Geometry

In this lecture, we continued to investigate Objective-C, and discussed the view hierarchy, including UIScreen, UIWindow, and UIView classes. We saw an example of a specialized view, UIImageView, that is built to display images. The instructor's incredible design skills were showcased in a demo of the open source GIMP software package.

Homework 2: View Geometry
Create an iphone application using the view-based template. Place two UIView objects onto the screen. Make one UIView object blue, and the other green.

Extra credit: use a touch event to move one of the blue UIView object around the screen.

Lecture 1 - iPhone/iPad Platform and Objective-C

In this lecture, the iOS Platform is introduced using the iPad and iPhone. The Objective-C language and its basic elements was introduced.

Objective-C is an extension of the ANSI C language which has been extended to include certain features centered around object oriented programming.

The following Objective-C extensions that are discussed and should be reviewed: @interface, @class, @property, [] (square brackets), #import, - (minus sign to mark an instance method), + (plus sign to mark an instance method).

UCLA_Day1_Demo project was created during class to demonstrate some of these concepts. See the readme.txt file in the iOS project for more information.

Homework 1: Getting Started
Send me an email with iOS in the subject line.
Read 'Learning Objective-C: A Primer' from Apple listed below.
Install the iOS SDK and XCode.
Create an iphone application using the view-based template. Display "Hello, World." on an instance of a UILabel. See UCLA_2012_HelloWorld.zip for a completed solution to the homework assignment.

Apple Documentation - Objective-C, A Primer. http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/

XCode Projects - Class Demos, Examples and Homework Answers


Class Logistics

Previous Versions of iPhone and iPad iOS Development class

home Site Map Terms of Use Privacy Policy Client Directories