CSC400-Mobile and Locative Computing Spring 2011

From CSclasswiki
Jump to: navigation, search



Week   Starting Goal
0 1/24 Xcode and Provisioning
1 1/31 Objective-C
2 2/7 UI Widgets
3 2/14 Putting it together (Todo list)
4 2/21 Sensors:GPS & Magnetometer
5 2/28 Sensors:Accelerometer & Gyroscopes
6 3/7 Making Sense of the Sensors: Location and Heading
7 3/14 Mapping and Location APIs
8 3/21 Notifications: Location (and time and/or push?)
9 3/28 Media I/O: Photo
10 4/4 Media I/O: Sound
11 4/11 Media I/O: Video
12 4/18 Fun w/ locative computing
13 5/2 Final's week: TBA


Friday: -

  • Document different types of xcode templates
  • working calculator (with documentation on inlets/outlets etc)
  • check into svn

Monday -

  • Todo Lists
    • Add items
    • delete items
    • check off items
    • filter items by date? priority?
    • sort items by date and/or priority?
    • view only completed items or undone?
  • more documentation
  • check into svn
  • Look into:
    • Persistent data storage
    • Changing views



The platform that we are targeting with this special studies is the iPhone and the iTouch, a mobile phone and media player respectively that are manufactured by Apple. As the current dominant platform for mobile social apps, the iPhone is the phone of choice for many -- while I couldn't find much conclusive research for 2011 yet, studies of the smartphone market for 2010 show that the iPhone had captured about 33% of the market share (meaning that given 3 people who own smartphones, one of them will be an iPhone.)

I am currently programming on my own second-generation 4-year-old iTouch, and a third-generation iPhone 3GS.


XCode is an IDE developed by Apple that can be installed on a Mac to develop (compile and build) Objective C/C/C++, Python, Ruby, and Java applications. It includes the Interface Builder, an application used to construct GUIs.

Objective C


  • ITunes University Course website
    • Stanford has a very popular course for download through ITunes University called "iPhone Application Programming". The course website then has other supplements like the lecture slides and homeworks available for download. While the lectures are time-consuming (considering they are recorded classes, after all), I have found them to be an effective way of quickly absorbing huge chunks of material.


  • Outlets

Outlets are instance variables in a controller that points to objects in a view.

  • Actions

These are methods in the controller that are going to be sent to us from the view.

Model View Controller



A delegate is just an object that another object sends messages to when certain things happen, so that the delegate can handle application-specific details the original object wasn't designed for. It's a way of customizing behavior without subclassing.

In Java, and in CS212, for example, you create card programs that handle mouseClicked events (amongst other things.) The equivalent would be to have a class (say Card) be able to directly 'receive' the mouseClicked event and deal with it within its code (by calling flip() or whatever behavior you wanted that specific class to have), rather than dealing with it in the main() function of the main class. In Objective C, you can do this with a delegate.

What is an application delegate? Every iPhone application (for the normal scenarios) will have one and only one (singleton) object of type UIApplication. This provides some basic functionality for running and managing an application. It usually interacts directly with data storage on the iPhone.

Guide to XCode

What Are All the Different Projects?

  • View-Based Application

Creates an empty View as well as a subclass to be your Controller (with a little bit of template code.)

  • Window-based Application

Creates an application with no View or Controller. This is the 'template-less' template.

  • Navigation-based Application

Creates a View populated with a table, meant for displaying information hierarchically. A Controller is provided.

  • Tab-bar Application

Creates an application with several Views which can be switched to through a tab bar. A Controller is provided.

  • Utility Application

An application that implements a main view and lets the user access a flipside view to perform simple customizations.

  • Split-View Application

This is only available for the iPad. Essentially you're able to nest different Views in each other, to achieve effects like drop-down menus.

Provisioning & Deployment Walkthrough

For the most part, I followed the steps outlined here.

Obtaining your certificate

The first step is to certify the computer you're programming your apps on -- to essentially prove that the apps uploaded are coming from a trusted source. When all the steps have been completed successfully, you will have a 'profile' in your Keychain (where all of your passwords are stored) that links you to the Smith College Development Team provisioning account.

Team Member/Student Step

  1. Using KeyChain Access in Applications/Utilities, go to Keychain Access -> Certificate Assistant -> Request a Certificate From a Certificate Authority. Enter the email address and name that you signed up for the iPhone developers' program with; instead of choosing to have it emailed to you, choose 'Saved to Disk' and make sure "Let Me Specify key pair information" is checked. Click continue.
  2. On the next screen, confirm that the certificate will be saved to your desktop, and that the Key Size is 2048 bits and the Algorithm is RSA.
  3. Here's where I ran into a gotcha -- you're supposed to then return to the Provisioning Portal, click Certificates, make sure it's on the Developer tab, then click "Submit certificates" and upload your certificate there -- but if you're using Chrome, you will see the error message "We are unable to upload this Certificate file because it is invalid. Please check the file and try again." no matter what you do. To continue, browse to the page in Safari or some other browser and upload your file there.

Team Admin Step

  1. An email should be sent to the Team Admin that says that a team member has submitted a certificate. They will need to log in and click 'approve'.

Team Member/Student Step

  1. Go back to the page where you uploaded your certificate -- under "Actions", there should be a link that says "download". Click it.
  2. Open the file ("developer_identity.cert"). Keychain Access should open with your new profile listed among the other passwords stored there.

Register your Device

Team Member/Student Step

  1. Using XCode, navigate to Windows->Organizer, and select your ipod from the list of devices. The string next to 'identifier' is the one you want. In my case, my iPod Touch's identifier is 974153964f60f6654f275a2c4f3bc194d8abd438.

Team Admin Step

  1. In the Provisioning Portal, navigate to "Devices" and then click "Add Device". Give the device a name, enter the identifier, and press submit.

Create an AppID

A new AppID needs to be created for an application -- it is essentially a unique identification string that allows the application to be identified by Apple's servers (as a legitimate app), communicate with other apps, and most importantly, be allowed to be installed on an Apple device.

Create a Provisioning Profile

As the final step, the provisioning profile will take the developer certificates, the device identifier, and the App ID, and create something to be installed on the test device that will (finally) allow apps to be installed on it.

Team Admin Step

  1. Go to the Provisioning tab in the Provisioning Portal. Under manage, click "Add".
  2. Specify a name.
  3. Specify which devices will be allowed to have the apps downloaded onto them.
  4. Specify which developers to include in the profile.
  5. Pick an App ID.
  6. Press submit.

Team Member/Student Step

  1. Go to the Provisioning Portal, and under the Provisioning tab, locate the appropriate profile. Click 'download'.
  2. Double-click the downloaded file (###.mobileprovision); if nothing happens, drag the file onto the XCode icon in your dock.
  3. It will ask you if you want to install the profile; click yes.

Download the App onto your Device

  1. Open XCode, and then your project. The upper left-most drop down box, which, when expanded, should display things like "Active Configuration" and "Active Executable", should have "Device" checked at the top.
  2. Click "Build and Run".

Hello World!


Hello World program

I followed the instructions on this handout, to use XCode to create a new Windows-Based Application that says simply "Hello World".

  1. Open XCode, click "Create New Project", and choose "Windows-Based Application" from the list (make sure that you are under "iOS" programs on the left.)
  2. XCode will automatically generate a bunch of files for you. Find the MainWindow.xib file and double-click to open it; it will automatically open in Interface Builder.
  3. One of the windows that should appear is the Library pane (if it doesn't, find it through Tools -> Library, or press Shift+Apple+L). This will give you a list of objects you can drag and drop onto the window. Scroll down until you see "Library - Cocoa Touch - Inputs & Values"; one of these things will be a Label. Drag and drop that onto the window and you will be able to resize it and edit the input.
  4. To add a picture, return to XCode, and from the toolbar choose Project -> Add to Project and browse to the picture you want to add. Make sure that "Copy items to destination group's folder (if needed)" is checked. Return to Interface Builder, and scroll up in the Library pane until you find the Image View. Drag it onto the window, adjust its position and size as needed, then in the "Image View Attributes" panel, choose the image you just added to your project.
  5. Save in Interface Builder before running.

To Do App



Location App


Accelerometer App


Magnetometer Overview


Gyroscope Overview

Sensor App Walkthrough

Sensor App Walkthrough and Code

To do:

  • Merge information as needed from GPS Location and Acc App pages.