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

This is our last lecture. You have come a long way in ten weeks!

In this lecture we cover device hardware: Compass, Accelerometer, Gyro. Core Location and the Core Motion API are covered. 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 10: Class Review, GPS and MapKit (Optional and involved, but highly recommended)

  • Create a UITabController-based application
  • On Tab 1, display raw GPS and Accelerometer data onto labels on the screen.
  • On Tab 2, display a UITableView with one row for each of your favorite restaurants. When a restaurant is selected, push a MapKit view onto the screen, showing your current location and the location of the restaurant.


Lecture 9 - Network connections with sockets and GameKit - 11/27/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.

Links that are related to tonight's lecture:

NodeJS - Host javascript socket servers
CocoaAsyncSocket - open source sockets library
Arduino - open source hardware device
Raspberry Pi - small Linux box on a board
CFNetwork Programming Guide


See the demos below from class:

ArduinoClient2.zip - uses CocoaAsyncSockect to send a UDP packet to an Arduino
UDPSendReceiveString.ino.zip - Arduino socket server example
NodeClient.zip - iPhone app client of a node.js server
socketServerWithFeedback.js.zip - node.js source for a simple socket server
webserver.js.zip - node.js source for a simple web server


Homework 9: Sockets and GameKit

Happy Thanksgiving. There is no official homework assignment for this lecture.

This would be a good time to catch up with family, then catch up on previous homework assignments.

Optional (and recommended) exercises:
  • Write an application that communicates through a socket to Node.js running on your MAC or on an external webserver
  • Pick up and Arduino or a Raspberry Pi and setup sockets communication between an iPhone app and the device
  • Setup Sockets communication between a web browser running the Sockets.IO javascript library and an iPhone app
  • Write a simple mac application in Python and communication with an iPhone app over Sockets
  • Write a sockets server in Ruby (pre installed on Mac OsX) and communicate with an iPhone application


Lecture 8 - Practical Internet Connections - NSURLConnection Delegate, Grand Central Dispatch (GCD) - 11/20/2013

This session we looked at pulling data from web servers in an asynchronous/non-blocking manner using NSURLConnection and it's delegate methods and through GCD.

We looked at helper classed like AsyncString which take care of many of the details.

See Day8-DemoAsync.zip and Day8-PracticalInternet.zip for some ideas.


Homework 8: Asynchronous Internet Resources
This is one of the most important homework assignments of the whole class. The due date for this homework is extended one week to 12/4/2013.
  • Create an iphone app with a UITableView
  • Using this url: slowitems.aspx?DelayMS=200 download the data using blocking code
  • Parse the downloaded text into an NSArray, and display the items on the UITableView. See the NSString documentation and look for a method that can parse the downloaded text into the array.
  • Repeat the exercise using NSURLConnection Delegate
  • Repeat the exercise using GCD
  • Repeat the exercise using a helper class that takes care of the hard work for you


Lecture 7 - Files and Internet Resources - 11/13/2013

In this lecture, we looked at methods of storing data and demonstrated parsing JSON and 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:

ConcertRecorder.zip - demonstrates recording audio files and storing them into the Documents Directory
RSSReader.zip - demonstrates parsing XML files, both locally and from a web server
Day7-DocsDirectory.zip - demonstrates reading and writing from the bundle and from the Documents Directory
Day7-GestureDemo.zip - review of hooking custom UIViews into the storyboard, custom view drawing and animation


Homework 7: Parsing an document from a webserver
  • Add a UITableView to an iphone application
  • Download either the XML document or the JSON document from the server we setup in class at: http://uclademoserver.certifiednetworks.com
  • Parse each of the nodes from the document into a NSArray of objects
  • Display the contents of the array on the UITableView


Lecture 6 - More view drawing, Animation with NSTimer and with CALayer - 11/6/2013

In this lecture we will wrap up our discussion of custom UIView drawing.

UIGesture and the touch events will be reviewed.

Animation techniques will be covered in class, including:
  • NSTimer and target/action
  • UIView Animation, with UIView blocks and with the "blocks" language feature
  • UIImage Animation
  • Core Animation and CALayer, CABasicAnimation and CAKeyframeAnimation
The .layer property of type CALayer behind every UIView object provides smooth hardware-accelerated animation. The CALayer Class also provides for helpful properties that affect views, such as rounded corners and dropshadows. CALayer Classes work much like UIViews in that sublayers are supported.

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

A project called CALayerAnimTest downloaded from http://nachbaur.com/blog/core-animation-part-3 will be demonstrated and discussed.

and Core-Animation-Demos from Bob McCune will be demonstrated and dicsussed:
https://github.com/bobmccune/Core-Animation-Demos .


Homework 6: Animation Techniques
  • Add four custom UIView objects to an iPad application
  • Inflate and shrink view1 using CABasicAnimation when it is tapped
  • Bounce view2 using CAKeyframeAnimation when it is touched
  • Continuously rotate view3 using NSTimer and target/action
  • Place a linear gradient at the base of view4, then use UIView block animation to change the position of view4 when it is double tapped
Be sure to take some time and experiment with the types of animation that can be performed, play with the parameters, and investigate the properties of CALayer.



Lecture 5 - Custom View Drawing - 10/30/2013

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

The Core Graphics C library is used to draw custom shapes into the CGContextRef of a UIView. The Core Graphics API is often called 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. Core Graphics techniques of drawing the user interface allow you to create a fully dynamic user interface that can be animated over time. See the custom UIView Classes in the demo created during lecture named Day5QuartzDemo.zip for hints.
  • Create an ipad application using the view-based template
  • Implement a custom UIView class named StarView which uses CoreGraphics to draw a star 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 StarView class on the screen in random positions of random sizes and shapes



Lecture 4 - UINavigationController and UITabBarController - UIViewController containers - 10/23/2013

In this lecture, UINavigationController and UITabBarController were presented.

Both of these Classes manage a collection of UIViewController objects, and manage the display of their views. The UINavigationController and UITabBarController both use the .title property of a UIViewController, and the UITabBarController also features a UITabBarItem that can be used to modify the display of a tab for any particular UIViewController.


Homework 4: UITabBarController and UINavigationController
  • Create an iphone application using the empty template.
  • Create a UITabBarController and set the self.window.rootController property equal to the UITabbarController.
  • Create three Custom UIViewcontrollers, one for each tab, as follows:
  • Tab 1, UIWebView displaying an interesting website
  • Tab 2, Place an interesting and large UIImageView on top of a UIScrollview, make sure the image is scrollable
  • Tab 3, UINavigationController housing a UITableViewController
  • Make the UITabbarController the .rootController property of the .window
  • Zip up the project folder and email it to Dave.

See the Day4TabDemo1.zip application from lecture for reference on how to set up the UITabBarController.

in class we walked through setup of the tabs in homework 4, creating TabBarDemo.zip and the following video:



Lecture 3 - UIViews, UIViewControllers, and inter-Class communication patterns - 10/16/2013

In this lecture, UIView objects were reviewed in the context of UIViewControllers. See the View Controller Programming Guide for more discussion of the UIViewController Class and it's many features.

The following communication patterns were introduced, and delegation covered in detail:

  • Delegation
  • Target/Action
  • Notification
  • KVO - Key/Value Observing


Homework 3: UITableViews
  • Create an iphone application using the view-based template.
  • Add a UITableView to the screen, using an NSArray object as the data
  • Zip up the project folder and email it to Dave.


Lecture 2 - Objective-C Continued, UIViews and specialized UIViews - 10/9/2013

In this lecture, more Objective-C language elements were reviewed.

The UIView class was covered in detail, and some specialized UIView objects were introduced as examples.

UIView concepts to review:
  • CGRect structure and CGRectMake() macro
  • UIView properties: .center, .frame, .alpha, .backgroundcolor
  • Affine transforms on a UIView: rotate, scale, translate
  • UIView animation blocks
  • UIView display hierarchy
  • UIResponder base class of UIView that provides touch and motion events


In class we created a few projects covering UIViews, including Day2ViewDemo which demonstrates most of the things you will need to know about UIViews


Homework 2: UIViews and specialized UIViews
  • Create an iphone application using the view-based template.
  • Make a UIView object appear on the screen when the screen is touched
  • Zip up the project folder and email it to Dave.


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

In this lecture, the iOS Platform was introduced while developing a sample application named Day1Demo. The Objective-C language and its basic elements were 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 were discussed and should be reviewed:
  • @interface
  • @implementation
  • @property
  • [ ] (square brackets)
  • #import
  • - (minus sign to mark an instance method)
  • + (plus sign to mark an class method)
  • @"Hello, World" - shortcut to create an instance of an NSString class


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 'Start Developing iOS Apps Today' from Apple. Apple Documentation - Objective-C, A Primer
  • Install the current production version of XCode - Version 5.0. 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.
Video: Homework 1 - Getting Started


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