Home > 2011 Winter DPS913 > DPS913 APD601 Lab 5

DPS913 APD601 Lab 5

February 18, 2011 Leave a comment Go to comments

Lab 5 gives you the opportunity to extend your efforts on Test 1 (the Daytona 500 drivers), by enabling editing of a driver’s information, as a third level of navigation. It is due on Friday, February 25.


DPS913 APD601 Lab 5 – due Fri Feb 25

Assigned: During Week 6

Due date: Friday, February 25, 2011, at 9:50am

Grade value: 3% of your final course grade

Grading method: The following will be checked:

  • Completeness and adherence to iOS app coding principles
  • Correct interactive operation of the app’s logic


Before you begin

Configure your Xcode environment as described in the “Before you begin” section of Lab 1. This will ensure that your work can be uploaded for grading.



Work with a navigation-based style application.

Work with the Core Data object management and persistence framework.

Know how to copy initial data from the bundle to the Documents directory.

Learn how to import data from a plist into a Core Data store.

Edit Core Data objects.


Concepts that you will learn

  • Navigation-based app style
  • Core Data stack
  • Configuring view controllers with properties
  • Editing Core Data objects
  • Save a UIImage in a Core Data store


Introduction to the problem that you will solve

The Daytona 500 is on Sunday, February 20, 2011.

You will “extend” your efforts from Test 1, by adding the ability to edit a driver’s data. You will add a third-level standard view controller, and enable the user to edit these attributes:

  • Finish – the driver’s finishing position in the race
  • Winnings – the amount of money the driver won
  • Photo – the driver’s photo/headshot


In the course programming examples download area, there is a refreshed “Daytona500Drivers” zip file. You can use these assets in your app. It includes the following:

  • Daytona.sqlite Core Data store file
  • DaytonaDrivers.plist original/source data
  • App icon
  • ReadMe file



Download the “Daytona500Drivers” zip file.

Create a Navigation-based Application, which uses Core Data for storage. Its name will be “Daytona”.

It will have three levels of navigation:

  1. Root – table view controller, showing driver names
  2. Standard view controller, showing read-only info about the driver
  3. Standard view controller, enabling the user to edit some driver info


The following screen shots show how the app works. The first screen shows the app when launched for the first time. When the user taps a row, the second screen, with driver info, is shown. The user can then tap the “Edit” button (in the upper-right), and show the third screen, enabling data editing.


Now, the user can enter “Finish” (an integer), and “Winnings” (an integer or a float). When the “Get photo” button is tapped, the driver’s photo is fetched from a specific URL. After the user taps the “Save” button (in the upper-right), the fifth screen shows the results; notice the added information. Finally, when the user navigates back to the root table view, notice that the driver’s “Finish” value has been prepended to his name.


The entity data model is shown below. You must create this entity:


The attributes are set as follows:

  • Driver, Car, Make, and Sponsor are String data types, all required (i.e. not optional)
  • Finish is optional, an Int 32 data type, with a default value of 99
  • Winnings is optional, a Float data type (and leave the default value as-is)
  • Photo is optional, a Transformable data type, that uses the value transformer named ImageToDataTransformer


You can copy the ImageToDataTransformer code from the Professors example app. As in that app, you can paste it into your app delegate’s .h header file, at the bottom.


Driver details view controller

This displays a read-only view, with driver info.

For all drivers, it will display the driver’s name, car number, make, and sponsor.

For drivers that have been edited, it will also display the driver’s finishing position in the Daytona 500 race, their dollar winnings, and a photo. The “Finish” and “Winnings” attributes are displayed in simple labels (which have text if the driver’s “Finish” attribute is less than 99), and the photo is a UIImageView (which will show a photo if one exists).


Driver edit view controller

This displays a view that enables the “Finish”, “Winnings”, and “Photo” attribute to be entered.

This view controller will have “Cancel” and “Save” buttons. Implement the pattern discussed in the “CD Complete” document/post, and in its code example.


Lab 5 guidance

You have two choices for getting data into your app – using a (provided) store file, or importing a (provided) plist.

If you choose to use the store file, you do as you were taught before: Simply include it in your app bundle, and when the app launches, copy it to the app’s Documents directory if it doesn’t already exist there.

If you choose to import from a plist, then add code to awakeFromNib:.

Before the Core Data stack is configured, check whether the store file exists in the app’s Documents directory. If not, set a (boolean) flag. See the following coding pattern:


Then, after the Core Data stack is configured, import the data, and add it to the Core Data store. See the following coding pattern:


Note that you do not have to setValue: for any of the optional attributes.


First (root) view controller

The driver list display task is uncomplicated.

You should use two sort descriptors. The first one is the “Finish” attribute data, and the second is the “Driver” name attribute data.

The default value for “Finish” is 99, which means that driver names will appear in alpha order before any driver edits are made.

Configure the visible row data to show the “Finish” attribute data, only if “Finish” is less than 99.


Second view controller

The driver info display task is uncomplicated.

You should set the user interface outlets in the viewWillAppear: method. This will ensure that it shows updated data after editing the driver’s info.


Third view controller

The driver editing task is uncomplicated. The only challenge is the photo.

The photo will come from a web resource. NASCAR stores the photo in a specifically-named file, in a specific location. We have to convert the driver’s name (e.g. “Dale Earnhardt Jr.”) into a string (e.g. “EARNHARDT_JR_DALE.png”) that can be placed in a URL.

The following guidance will teach you about string manipulation tasks. Make sure you read the reference material to learn more.


After you create the string, you can follow the coding pattern that you saw in the Professors example app to fetch (and display and save) the photo.


Send me your work

Make sure that you have configured your Xcode environment to avoid sending the intermediate build files. This will ensure that your uploads to me are the right size.

Follow these instructions to send me your work:

  1. Make sure your project works correctly
  2. Locate your Daytona project folder in Finder
  3. Right-click the folder, and choose Compress “Daytona”, which creates a zip file
  4. Visit this page: http://matrix.senecac.on.ca/~peter.mcintyre/dps913/, and upload Daytona


Categories: 2011 Winter DPS913
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: