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 - CoreMotion, MapKit, Over the Air (OTA) Deployment - 6/19/2013

In this lecture we cover device hardware: Compass, Accelerometer, Gyro. Core Location and the Core Motion API are covered. Example_Location.zip demonstrates passing location data from Core Location to the google maps website as part of the query string.



In class, we will attempt to demonstrate an Over The Air (OTA) deployment - providing a downloadable link for installing an app on devices for testing purposes.


Homework 11: GPS (Optional, but highly recommended!)

  • Create a UITabController-based application
  • On Tab 1, display raw GPS and Accelerometer data onto the screen.
  • On Tab 2, display your current location on a map


Lecture 10 - Integrating HTML5, audio and video into your application - 6/12/2013

In this lecture we discuss integrating HTML5/CSS/Javascript and multimedia into iOS applications. There is a blog post linked here techno-barje.fr which discusses calling Javascript from Objective-C, and Objective-C from Javascript.

Video will be integrated using MPMovePlayerController.

See Example_Video.zip for an example of playing a local .mp4 video file from the app bundle.

If you will stream video to the iPhone or iPad over cellular networks, you are required to send the video in HLS (HTTP Live Streaming) format. See HTTP Live Streaming as a starting point.

Using Audio from Apple Developer is a great point to start your reading on audio integration.

The following is an example of how to play a simple sound effect:

- (void)playNoise
{
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"noise" ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
AudioServicesPlaySystemSound (soundID);
//[soundPath release];
}

HTML5 game tutorial from Six Revisions - very interesting coverage of HTML5 features


Homework 10: Video and HTML5

  • Record a video of something family friendly and interesting.
  • Encode the video to .mp4 format using Handbrake.
  • Create a tab-based application with two tabs
  • Include the video in both tabs, one tab using MPMoviePlayerController and the other tab using HTML5 video tag in the HTML displayed by UIWebView


Lecture 9 - Network connections with sockets and GameKit - 6/5/2013

In this lecture we cover networking with sockets in the iOS environment, looking at a third-party library called CocoaAsyncSocket which helps wrap the sockets classes. The GameKit classes will also be covered.

NodeJS - Host javascript socket servers
CocoaAsyncSocket - open source sockets library
Arduino - open source hardware device
CGNetwork Programming Guide


Homework 9: Sockets and GameKit

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

Lecture 8 - Asynchronous Internet, JSON - 5/29/2013

In this lecture, we look at practical methods of interacting with data dowloaded from Internet servers.

Topics Include:

Singleton Pattern
Caching Data in a Central Class
Setup of Ubuntu Apache Web Server using AWS, PHP and MYSQL
Asynchronous Download of JSON Data
Parsing JSON Data into objects

In this video the setup of a new PHP/MYSQL webserver at AWS basic is demonstrated.
Direct link to the file:iphone-aws-demo.mp4

Homework 8: Parsing a JSON feed
  • Create a view-based application
  • Parse the JSON feed we created in class at http://ucla.certifiednetworks.com/jsonservice.php into an array of custom objects or an array of NSDictionary objects using Apple's NSJSONSerializer Class
  • Use GCD to parse the JSON feed in a background thread
  • Add a UITableView to the screen to display the parsed data


Lecture 7 - Files and Internet Resources - 5/22/2013

In this lecture, we looked at methods of storing data and demonstrated parsing of XML documents.

Both NSString and NSData support loading from a file or from a URL.

As an example, you might load an XML file and setup an XML parser from a file in the bundle with the following Objective-C code:
NSURL *url = [[NSBundle mainBundle] URLForResource:@"famousDrummers.xml" withExtension:nil];
NSData *bundleData = [[NSData alloc] initWithContentsOfURL:url];
 
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:bundleData];
parser.delegate = self;
Working with data downloaded from Internet servers was introduced. In the next lecture, we will build on this topic and make the download of data occur in a background thread, freeing up the UI for interaction with the user.

Example projects below include:

Day7_DocumentsDemo1.zip - Basics of reading/writing to the Documents directory
Day7_InternetDemo.zip - Pulling data and text from web servers
Day7_PlistTableView.zip - Reads a .plist file into an array
ConcertRecorder.zip - demonstrates recording audio files and storing them into the Documents Directory
RSSReader.zip - demonstrates parsing XML files, both locally and from the Internet


There is no official homework assignment for this lecture. You may want to start investigating parsing XML documents.

Lecture 6 - iOS Animation - 5/15/2013

In this lecture, we cover basic animation techniques available in the iOS SDK, including:
  • Scheduled NSTimer and your own run loop
  • UIView Animation (old style and with blocks)
  • Core Animation
  • UIImage animation

CALayer is a Class that is leveraged by UIView, and is important in providing smooth hardware-accelerated animation. It also provides a number of interesting properties, such as rounded corners and dropshadows. At least one CALayer object is at the base of each UIView object, and it supports adding sublayers much like UIViews support subviews.

Core Animation Programming Guide at apple.com is a great reference. Also Ray Wenderlich's CALayer Tutorial and UIView Animation are nicely done.

UITouch events are reviewed in class and UIGestureRecognizer subclasses were covered in detail.

During lecture, a project by Bob Mccune was demonstrated that contained just about every type of Core Animation and CALayer property: http://bobmccune.com

This demo at github demonstrates CABasicAnimation /CAKeyFrameAnimation and shows some interesting coding techniques.

Homework 6: Animation

The goal of the assignment is to gain experience with various animation techniques.
  • Create a view-based application with three subviews - red, green and blue
  • Use a UITapGesture to animate each subview when it is touched
  • Animate the first subview using UIView Animation
  • Animate the second subview with a manual NSTimer event
  • Animate the third subview using CABasicAnimation or CAAnimation

Lecture 5 - Custom View Drawing - 5/8/2013

In this lecture, we looked at the drawRect method of a custom UIView.

The Core Graphics C library is used to draw custom shapes into the UIView. Sometimes people refer to the Core Graphics API with the name Quartz or Quartz 2D.

See the Quartz 2D Programming Guide at apple.com for more in depth information about working with Core Graphics.

Homework 5: Custom View Drawing
In this lab, you will investigate drawing custom UIView objects with Core Graphics. Many of the more creative iphone and ipad applications use this technique to create a unique and dynamic user interface.
  • Create an ipad application using the view-based template
  • Implement a custom UIView class name HexagonView which uses CoreGraphics to draw a hexagon shape
  • Using the bounds property of the UIView, draw a hexagon that fills up as much of the UIView as possible
  • Draw five instances of the HexagonView class on the screen in random positions of random sizes and shapes
  • Change the position and size of the objects on the screen in the touchesBegan event of the UIViewController


Lecture 4 - UITableView, UINavigationController - 5/1/2013

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

The UINavigationController class is reviewed. 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.

UITabBarController class is introduced. The UITabBarController presents tabs at the bottom of the screen, each representing a separate UIViewController instance. The UITabBarController is similar in nature to the UINavigationController.

Homework 4: UITabBarController
  • Create an iphone application using the empty template
  • Add a UITabBarController to the AppDelegate, initializing it with three UIViewControllers
  • Tab 1:UIViewController that holds a UITableView. When you tap a cell, a detail UIViewController is presented.
  • Tab 2:UIViewController that presents a web page
  • Tab 3:UIViewController that displays a scrollable UIImageView


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



Lecture 3 - Delegation and UITableView - 4/24/2013

In this lecture, we 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 in iOS work in the same manner. 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 a basic UITableView is demonstrated.
http://git.certifiednetworks.com/videos/iphone/Day3_TableView.mp4 17.2MB 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.



Lecture 2 - More Objective-C, Specialized UIView Objects, Target/Action - 4/17/2013

In this lecture, we review the startup process of an iOS application from main() to the UIApplicationDelegate's application: didFinishLaunchingWithOptions: method. We continue to investigate Objective-C classes, including properties.

The UIView hierarchy is reviewed, and a few specialized UIView objects are demonstrated.

The target/action pattern is introduced and an example of this pattern is demonstrated with a UIButton.

Review this wikipedia link on the Target/Action software pattern.

The 'target' of the UIButton will typically be the UIViewController, and the 'action' will be a method that has been defined and implemented by the developer in the UIViewController Class.

Homework 2: Specialized UIViews and Target/Action
  • Create an iphone application using the view-based template
  • Place a UITextField, UILabel and UIButton into the view hierarchy
  • Define a method that reads the contents of the UITextField and sets the .text property of the UILabel
  • Use target/action on the UIButton to call your method when the TouchUpInside event is fired


Lecture 1 - iPhone/iPad Platform and Objective-C - 4/10/2013

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

Objective-C is an programming language that features extensions of the ANSI C language. These extensions that have been added are mostly centered around object-oriented programming: creating Classes and working with methods on the Classes.

The following Objective-C syntax 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 class method)


Homework 1: Contact Info, Setting Up Your Development Environment, Basic App
  • Send an email to Dave at dhenson@certifiednetworks.com with iOS in the subject line. This is important so your email address can be whitelisted.
  • Read 'Learning Objective-C: A Primer' from Apple. Apple Documentation - Objective-C, A Primer
  • Install the current production version of XCode - Version 4.6.1. This will likely need to be updated before our class is over.
  • Create an iphone application using the "empty application" template.
  • Display a red UIView object on the screen.
  • Zip up the project folder and email it to Dave.


Back to Top

XCode Projects - Class Demos, Examples and Homework Answers

Slides

Class Logistics

Previous Versions of iPhone and iPad iOS Development class

External Links

home Site Map Terms of Use Privacy Policy Client Directories