CMSC 498i
CMSC 498i
Lecture #24 – “Complete Apps” – Icons+Graphics, Settings, UnitTests, ObjC Fun
Today we discussed a variety of topics centered around creating complete application. Want to produce a polished shipping application, you’ll increase your products value by making proper use of Icons and Graphics, and giving users app Settings. To produce quality application, add unit testing to your application, and run those unit test every time you build your app. Finally, we took a look at some of the horsepower behind the Cocoa frameworks, the Objective-C runtime. We talked about the possibilities it enables – both for good and evil… With great power, comes great responsibility (or so I’ve heard…)
Downloads
24_IconsSettingsUnitTestObjCFun.pdf
Lecture #23 – “Complete Apps” – Localization, Undo, Copy/Paste, Accessibility
Today we discussed a variety of topics centered around creating complete application. Want to sell your application in multiple countries, you need to understand localization issues. In addition, users expect features like copy/paste and undo in polished applications. Finally, we saw how very little effort is required to make your applications more accessible by users with disabilities. Every application should be accessible.
Downloads
23_LocUndoCopyPasteAccessibility.pdf
Lecture #22 – Semester Project Details; Misc Topics
Today, we spent most of our time waiting for my laptop battery to charge…
Once up and running, we went through the remaining schedule for project presentations / submissions, and final exam. We discussed presentation expectations and logistics. Then I gave an example presentation for my own pretend semester project (example presentation linked below). With the remaining time, we covered some miscellaneous topics that have not fit anywhere else yet. The slides include performance tips and tricks, Address Book API info, UTI, proximity sensor API, how to integrate with other apps on the system, network reachability API, and more…
Downloads
ProjDetailsExample – presentation details, and an example of what one might look like.
Lecture #21 – Performance: Concurrent Programming
Today we discussed concurrent programming topics and APIs. We learned how to create multiple threads using high level threading APIs. We saw how to protect data access using various locking strategies and discussed what it means to be thread-safe. Finally, we introduced operation / queue based threading APIs provided by the foundation framework.
Downloads
Demo and Sample Code
LetsMakeAThread - (from CS193p) Create a thread & messages main thread when done (UIKit is not thread-safe)
ImageFinder - Shows how to load images from the internet (single images, and in table cells) concurrently
Reading
–Chapter 1 – About Threaded Programming
–Chapter 4 – Synchronization
–Thread Safe Designs, p.62 - 64
–Using Locks, p.67 - 71
Lecture #20 – Performance: CPU, Memory, Battery
Today we discussed the importance of good performance in your applications. Mobile devices with limited resource require attention to detail when it comes to using the processor, memory and battery. We saw how to use Xcode’s “Instruments” tool to analyze code performance, memory usages, and even find leaks. In addition, we saw that static analysis could help us find potential problems (like memory leaks) at compile time.
Downloads
Reading
iPhone Application Programming Guide
– Tuning for Performance and Responsiveness (p.41 - p.45)
–Chapter 1 – Instruments Quick Start
–Chapter 5 – Viewing and Analyzing Trace Data (thru p.58)
–Chapter 8 – Built–in Instruments; Sections on: ObjectAlloc, Leaks, Sampler
Memory Usage Performance Guidelines
Lecture #19 – Location & Maps
Today we discussed location and mapping services. We discussed various technologies for acquiring location and how that impacts your choice and use of location API. In particular, it is important to only ask for location accuracy you need and to tell the system to stop sending updates whenever possible to help conserve your user’s battery. From the UI side of things, we saw how you could customize the display of location data using MapKit to allow users to interact with that data in meaningful ways.
Downloads
Demo and Sample Code
WebAndMap Demo – (Adapted from Stanford’s CS193p) Shows meaningful ways to integrate map display.
CoreLocation Demo – Shows how to efficiently acquire location data to a specified level of accuracy. This demo goes to great lengths to turn off location updates when not needed..
Lecture #18 – Networking with Bonjour / GameKit
Today we learned how to use the Bonjour and GameKit APIs to build ad-hoc network. Using these APIs we can publish services which others can find and connect. With NSNetServices (Bonjour) we publish, browse, and then connect to a NSNetService. After resolving the NSNetService, input and output streams can be acquired and used to send and receive data between client and server. With GameKit, we use GKPeerPickerController to browse for and connect GKSessions which provide all the API we need to send and receive data.
Downloads
Demo and Sample Code
Bonjour Message – Send simple messages (displayed as UIAlerts) between connected clients.
GameKitSample – Communicate (and display) the movement of an on screen box to all connected clients
TicTacToeNew – Good example supporting Bonjour (OnlineSession) and GK (GKSession) simultaneously.
Lab #9 - Drop The Puck
You will be writing a simple game. A user will position the puck and goal using their fingers and then move the puck by tilting their device. They win when a goal is scored. You will practice processing multiple touches, learn to work with UIAccelerometer (making use of the low–pass filter discussed in class), and learn to play an audio file.
Downloads
Lab9_DropThePuck.pdf – lab instructions, with screenshots!
Lab9_DropThePuck_resources.zip – resources you’ll need to complete the lab
Lab9_DropThePuck_demo.zip – reference demo.
To use the demo app, read the simulator and device app Installation Instructions
Lecture #17 – Audio, Video, iPod
Today was all about media – playing short system sounds, longer songs, video, and even accessing and playing content from the user’ iPod Library.
Downloads
AV Demo – Play short / long sounds and videos using AudioToolbox, AVFoundation, and MediaPlayer APIs.
MusicSearchDemo – Searches for albums in the user’s iTunes Library and provides UI for playing the matches.
Assigned Reading
System Sound Services Reference
AVAudioPlayer Class Reference - Read the overview section
Getting Started with Audio & Video - Just browse the overview to get an understanding of where things live.
Lecture #16 – OpenGL ES, Accelerometer, Multi-Touch
Today we started in on Gaming related technologies on iPhone OS. Starting things off – we examined the basic structure of an OpenGL ES / UIKit application. Today’s demo code showed how to customize drawing in the standard Xcode OpenGL template. After that, we added touch handling that allowed the user to move and resize the GL content. Finally, we learned how to access the accelerometer on the iPhone and filter its data in useful ways. Using a low–pass filter, we can isolate and approximate the effects of gravity by filtering out more instantaneous motions.
Downloads
16_OpenGL_Accel_MultiTouch.pdf
OpenGL demo code – Draws a square using OpenGL which the user can move, and resize (by pinching).
Assigned Reading
iPhone Application Programming Guide
– Accessing Accelerometer Events: p.173 – 176
Sample Code - read and understand one of the following demo code’s use of UIAccelerometer
Lab #8 - Weather XML (WebServices, XML, Persistence)
You will be writing an application to display a 5 day forecast (high temperatures) for zip codes entered by the user. This project focuses on using WebServices, and parsing XML responses with NSXMLParser. Additionally, you will be asked to archive application state using an NSCoding / NSKeyedArchiver.
Downloads
Lab8_WeatherXML.pdf – lab instructions, with screenshots!
Lab8_WeatherXML_resources.zip – resources you’ll need to complete the lab
No demo application is provided, instead refer to the screenshots in the handout.
Lecture #15 – WebServices, Parsing XML, SQLite
Today we focused on web services and saw how to issue requests to the cloud and parse responses. We focused on event driven parsing and NSXMLParser, but got to see a little bit of libxml2, TouchXML’s tree-based and XPath functionality. In addition, we touched on JSON and saw how simple it could be to use.
Finally, with the extra time we had at the end, we began looking at SQLite. Basics of SQL as understood by SQLite were presented using the command line sqlite3 tool to demonstrate their use. We did not talk about the C-API, but they are included in the lecture material here for your reference.
Downloads
SimpleImageSearch demo code – Request image data using the Yahoo! image search APIs.
Assigned Reading
Event-Driven XML Programming Guide for Cocoa
– Intro, Parsing Basics, Handling XML Elements and Attributes: p.7 - 18
Other Resources - not required, but very useful
– Libxml tutorial –!http://xmlsoft.org/tutorial/xmltutorial.pdf
– NSXMLParser example –!http://weblog.bignerdranch.com/?p=48
– “Introducing JSON” –!http://www.json.org/
Lecture #14 – Data Persistence
Today we covered data persistence – writing and reading data. We reviewed property lists and discussed its uses and limitations. The next logical step, creating our own generic and flexible archives was presented. By conforming to the NSCoding protocol, we can archive arbitrary object graphs into an NSData. This data can be written to file, or sent to other applications on remote hosts for example.
Downloads
SimpleCoder demo code – Shows a simple NSCoding example. Adds NSCoding support to the ToDoEvent class.
Assigned Reading
Archives and Serializations Programming Guide for Cocoa
– Archives: p.9 - 19
– Encoding and Decoding: p. 21 - 30
** Ignore sections on “Serializations” and any “Non Keyed” archive discussions
Lab #7 - Animatron (Graphics & Animation)
We are going to have some fun with animation. You will be creating customized and coordinated animations and learning the basic image and text drawing APIs UIKit provide. In a addition, you’ll have the chance to practice writing more touch input handling code.
Downloads
Lab7_Animatron.pdf – lab instructions, with screenshots!
lab7_Animatron_resources.zip – resources you’ll need to complete the lab
lab7_Animatron_demo.zip – contains a demo for both the simulator and device.
To use the demo app, read the simulator and device app Installation Instructions
Lecture #13 – Animation
Today we covered UIKit and CoreAnimation animation systems. We learned strategies for using UIView animations to customize and coordinate animatable property changes. We also touched on CoreAnimation and the additional power and control it can provide if you are willing to dive in and learn more.
Downloads
AnimDemo - A simple app that places a box when a tap comes in, and animates it to a new position on double tap.
CurlAndFlipDemo - A simple demo showing of how to flip and curl full screen views
Assigned Reading
iPhone Application Programming Guide
– Animating Views: p.67 - 72
– Touch Events: p.81 - 94
Core Animation Programming Guide
– What is Core Animation: p. 13 - 19
Lecture #12 – Drawing / Graphics
Today we learned about UIKit and CoreGraphics drawing systems. We discussed how the iPhone graphics and rendering systems function so you can understand where your drawing code fits and how you can best optimize performance. We covered drawing primitives, and graphics contexts in both UIKit and CoreGraphics.
Downloads
Assigned Reading
iPhone Application Programming Guide
– Layout, Redrawing: p.71 - 72
– Graphics and Drawing: p.107 - 118
– Paths: p. 47 - 58
– Transforms: p. 79 - 85
Midterm Reference - Answers
A copy of the midterm complete with possible answers is available in the MidtermReference.pdf document.
Lab - Extra Credit - Pickers
This project focuses on using services provided by UIViewControllers that you can drop into your applications. Download the handout for details.
Downloads
Lab_Pickers.pdf – lab instructions, with screenshots!
lab_Pickers_resources.zip – resources you’ll need to complete the lab
– Follow previous instructions for how to install and run the demo app in the simulator
Lecture #11 - Text Input
Today we learned how to present the keyboard and gather input from users. We discussed the text related events (notifications, delegate messages, target/action) provided by UITextField and UITextView. We saw that the keyboard is configured by modifying “text traits” attached to these containers. We discovered that UIKit provides no show / hide keyboard API, and instead presents and dismisses the keyboard automatically based on the whether or not the first responder has text traits.
At the end of class we dug into unicode a bit. Unicode terminology is used in some NSString APIs. A familiarity with some unicode terms will help you understand how to more effectively and correctly work with international text and NSStrings.
Downloads
demo_KeyboardFun.zip – This is a little demo app that shows of the keyboard, and text input.
Semester Project Information
Project requirements and dates for milestones are listed in the SemesterProject.pdf document.
Device Development – Preparation
In order to build and install an application on an iPhone or iPod Touch during a project development cycle, there are a few steps you need to take. There are two phases you must complete, each consisting of multiple steps outlined in the DeviceSetup.pdf document. Please make sure to complete phase 1 before spring break.
If you own multiple machines you intend to code from, you will also want to read the page which explains how to copy the code signing resources (certificate / private key pair) from one machine to another.
Lecture #10.2 – Mini Survey of Technologies on iPhone SDK
Today we took a really quick tour of the technologies in the iPhone SDK that we have not yet discussed. You should now have an idea what is out there and which we’ll discuss in depth later in the semester. This should help as you scope and propose your semester project. Depending on what you are doing, you may need to learn some of the technologies on your own, but you should know where to find them and get started now.
Downloads
Lab #5 - iNeedToDo (View Controllers)
The ToDo application is being extended for the last time! When done, you’ll have an application that allows users to input new todos, edit existing items with changes being saved across application launches. The goal is to learn how to use view controllers, and work on good application design for data passing. Download the handout for details.
Downloads
Lab5_ViewControllers.pdf – lab instructions, with screenshots!
lab5_resources.zip – resources you’ll need to complete the lab
1.Install the unzipped folder
2.Place it at ~Library/Application\ Support/iPhone\ Simulator/User/Applications
3.Then quit and relaunch the Simulator to see the demo app!
Lecture #10 – View Controllers #2
Today we finished up our coverage of view controllers. We learned about standard UIViewController methods you’ll want to use and override when creating your own view controllers. We also spent time looking at examples of real application flows pieced together using UITabBarController and UINavigationController and saw the API for their companion classes like UINavigationItem, UIBarButtonItem, etc. Finally, we discussed modality, rotation of view controllers, and how to provide editing features. At the end of class, everything was pieced together with a quick demo that has been cleaned up for download below.
Downloads
Demo Code – demo_HelloNavigation.zip
Assigned Reading
Read “View Controller Programming Guide For iPhone OS”
In addition to the reading associated with Lecture #9, read the following section
“Combined View Controllers” – p.97 - 103
UINavigationController Class Reference
UINavigationItem Class Reference
UIBarButtonItem Class Reference
Lecture #9 – View Controllers - Intro
Today we got started with View Controllers. We discussed subclassing UIViewController and UITableViewController to provide custom screens in your application. We also learned how to use UITabBarController and UINavigationController to piece together an “application flow”. Finally, we discussed using support classes like UINavigationItem to configure what is displayed in the UINavigationBar (instead of directly manipulating the view).
Downloads
Assigned Reading
Read “View Controller Programming Guide For iPhone OS”
“About View Controllers” – p.11 - 20
“Custom View Controllers” – p.21 - 52
UIViewController Class Reference
Solutions - Lab #3, Bubble Game
Please take a look at the solutions and make sure to ask questions about anything you don’t understand.
Downloads
Devices
Eventually we will want to break free of the simulator and start running some code on live devices. To do this, there are a couple of things everyone will need to do. The goal is to get a Development Certificate on your Mac and device Provisioning Profile on your device (If you are using your own device). There are 2 phases. In the first phase, you submit a bunch of information. Then you can go home and wait until we tell you to do the second phase.
Instructions
Lecture #8 – Architecture & MVC
Today we discussed good ways to organize and architect your applications. We discussed the Model View Controller design pattern, various schemes for sharing data, and ways you can propagate changes through your application.
Downloads
Assigned Reading
Read “The Model-View-Controller Pattern”, P.158 - 166 from CocoaFundamentals.pdf
(skip the parts about NSObject/Array/TreeController)
If you are interested, read up on KVC/KVO: Key-Value Programming Guide, Key–Value Observing Guide
Lab #4 - iNeedToDo (Tables)
The ToDo application is being extended to display two different editable views. Download the handout for details.
Downloads
Lab4_Tables.pdf – lab #1 instructions
lab4_resources.zip – resources you’ll need to complete the lab
1.Install the unzipped folder
2.Place it at ~Library/Application\ Support/iPhone\ Simulator/User/Applications
3.Then quit and relaunch the Simulator to see the demo app!
When you are done with Lab #4, you’ll have a ToDo management application that looks something like this

Solutions - Lab #2, Memory Management
Please take a look at the solutions and make sure to ask questions about anything you don’t understand.
Downloads
Memory Management Assignment - Person.m
Lecture #7 – Tables
Today we learned how to use UITableViews. We discussed the delegate / data source pattern works and covered displaying data with UITableViewCells.
Downloads
Assigned Reading
TableView Concepts Documentation - ( TableView_iPhone.pdf ) – Read Chapters 1, 2, 4, 5, 7, 8
Read Overview, and Tasks sections for – UITableView -- UITableViewDataSource -- UITableViewDelegate
Lab #3 – Bubble Game
Today we break away from the paint-by-numbers style labs we’ve been doing and will start writing more code. You are going to be provided with a set of code to get you started and adding your own to make a game that displays bubbles that users can pop with their fingers.
Downloads
Lab3_BubbleGame.pdf – lab #1 instructions
lab3_resources.zip – resources you’ll need to complete the lab
When you are done with Lab #3, you’ll have a game that looks something like this

Lecture #6 – Intro to UIView and UIControl
In this Friday’s Lab, we’ll learn more about UIView including how the infrastructure for drawing and view composition works. We’ll learn how to create UIControls and connect them to our code using target / action. Finally, we’ll take a quick tour of some of the simpler UIControl subclass that UIKit provides for you to use right out-of-the-box.
Downloads
Assigned Reading
UIControl Class Reference – Read - p.5, 11-12, 17-22
UIKit Framework Reference – Browse the list of classes to see what is available...
Lecture #5 – Intro to UIKit and UIView
Today we learned a bit about a Cocoa application lifecycle and the basics you need to create an interactive application. We discussed how to make connections to views created in your Interface Builder XIB documents. We also covered how to make and work with views in code.
Downloads
Assigned Reading
“iPhone Application Programming Guide” - Read Chapter 2, “Windows and Views” p.47 - 77
Class References – Read the “Overview” and “Tasks” sections for each
Assignment - Memory Management
We can all use a little additional practice with Cocoa memory management. Getting it right is very important. Missed retains lead to crashes, and missing releases lead to leaked memory which is bad on an embedded device with tight memory constraints. Complete the memory management assignment to show of how well you’ve learned these concepts.
Downloads
MemoryManagementAssignment.pdf
Lecture #3 / #4 Overflow Material
We had a little bit of material we didn’t get to during lecture #3 and #4 that we finally got to discuss after about a week and half snow break. Today we covered NSURL, PropertyLists, and Date related programming topics.
Downloads
Assigned Reading
Read the following from CocoaFundamentals.pdf:
•P.70-74 - “The Root Class”
•P.34-40 - “Foundation Classes”
•P.94-98 - “Object Mutability”
Class References – Read the “Overview” and “Tasks” sections for each
•NSArray class reference
•NSDictionary class reference
Read the following from “Date and Time Programming Guide”
•“Dates” – p. 9-11
•“Calendars, Date Components, and Calendar Units” – p.11 - 14
•“Calendrical Calculations” – p.15 - 18
•“Time Zones” - p. 19
Lab #1 - Solution
Please let us know if you didn’t receive an email with your score and feedback on your code. We won’t be posting solutions to every lab, but early on we want to you to see examples of as much objective-C code as possible. To that end, we’ve been giving you lots of source with each assignment, and will be posting solutions to the first couple of labs. Your code does not have to look exactly like the solution below, but should look very close. Please take a look, the code is heavily comments explaining everything that is going on.
Downloads
Lab #2a – Debugging Practice
You will be taking some pre-written code and debugging it. Once it works, you’ll have a functioning calculator application that displays a history of the previously calculated values.
Downloads
Lab2a_Debugging.pdf – lab #1 instructions
lab2a_resources.zip – resources you’ll need to complete the lab
Lab #2b – Property Lists, NSArray, NSDictionary
You will be learning to work with Property Lists, and NSArray / NSDictionary APIs. You will be providing implementations for a couple of methods that are stubbed out in the ToDoEvent class. Once you’ve done this, you will be able to read events from a property list and display the data in a variety of sorted formats.
Downloads
Lab2b_ArrayDictionaryPlist.pdf – lab #1 instructions
lab2b_resources.zip – resources you’ll need to complete the lab
Lecture #4 – Intro to Foundation, Cocoa’s Collection Classes
Today we got more acquainted with the basics of Cocoa’s Foundation framework. We discussed some of the basic collection classes including NSArray, NSDictionary and their mutable counterparts. In addition, we learned a little bit about property lists and saw how you can use them to store any of the basic value, and collection classes in Cocoa. We also saw how easy one can use NSArray and NSDictionary APIs to write and read property lists with ease.
Downloads
Assigned Reading
Read all of Collections.pdf to learn more about Cocoa’s collection classs. This is pretty short...
Become familiar with documentation for NSString, NSArray, NSDictionary - Class References
If you are interested in the history of “Cocoa”, read p.57-58 in CocoaFundamentals.pdf
Lecture #3 – Intro to Foundation, Cocoa’s Value Classes
Today we got acquainted with the basics of Cocoa’s Foundation framework. We discussed some of the basic value classes including NSString, NSNumber, NSDate etc. In addition we learned a little bit about how Core Foundation and Foundation relate to each other, although you will typically be able to stick to using just the Foundation level.
Downloads
Assigned Reading
Read the following from CocoaFundamentals.pdf:
•P.70-74 - “The Root Class”
•P.34-40 - “Foundation Classes”
•P.94-98 - “Object Mutability”
Objective-C Notes
I’ve posted some notes here that will hopefully clear up some of the confusion folks were having during lab #1. You can find those note here: Objective-C Notes #1.
Submission Information
When you are ready to submit your lab...
1)delete the folder named "Build" in your project’s folder, that contains big object files we don’t want...
2)Control-click the folder in a Finder window and choose the compress option from the context menu
3)Go to submit.cs.umd.edu and upload zip that was created in step #2. Upload to the corresponding lab project.
Lab #1 – Getting Started
Today you will be getting acquainted with Xcode, and the debugger. You will also be given your first chance to write some very basic Objective-C code for a “ToDoEvent” model object.
Downloads
LabAssignmentsOverview.pdf – an overview of what is expected of your lab assignments.
Lab1_GettingStarted.pdf – lab #1 instructions
resources.zip – resources you’ll need to complete the lab
When you are done with Lab 1, this is what you should see (don’t worry about the specific dates if they don’t match....)

Lecture #2 – Objective-C basics, Memory Management
Today’s lecture covered the basics of Objective–C including basic types, messaging syntax, subclassing, properties and Objective-C 2.0, and memory management.
Downloads
Assigned Reading - [ please read the sections mentioned at the end of the lecture slides ]
http://cocoadevcentral.com/d/learn_objectivec – a nice tutorial / introduction to objc...
Lecture #1 – Overview, Tools & Objective-C Intro
Today’s lecture gave an overview of the CMSC 498i. We are looking forward to an outstanding semester and hope today’s intro will get every one off and running on solid ground. We discussed an overview of the iPhone OS architecture, the tools that are available and briefly touched on Objective–C and its syntax.
Reading was assigned at the end of the lab. Please make sure to follow the links at the end of the lecture and read the material before the first lab. It is important to get up to speed on the basics as quickly as possible since the lectures and labs will build on each other and move quickly.
Downloads
Page Last Updated: Chuck Pisula – 5/24/10
Lectures & Labs