Assignment 3

Due Date

Thursday, October 1st — 11:59pm


This project is designed to give you some hands on experience with…

  • Using Xcode as a development environment
  • Using Interface Builder to create iPhone user interfaces
  • Declaring and wiring outlets and actions
  • Testing applications in the iPhone Simulator
  • Exposure to additional user interface elements
  • Using delegates and dataSources for a variety of purposes


For this assignment you will be writing a converter app for the iPhone. Your application must contain the following elements…

  • A toolbar containing a centered segmented control that allows the user to choose between 2 or more different categories
  • A picker wheel that allows the user to choose between units of conversion (a “from” and a “to”)
  • A customized set of buttons that allow the user to specify and edit the “from” value. This set of buttons should include:
    • The numbers 0-9
    • A decimal point
    • A delete (backspace)
  • A label that is used to display the “from” and “to” values


When your app initially loads it should look similar to the image shown below:

Initial State

Initial State

When a user presses a button, the number should instantly appear in the “from” label under the left wheel (just like a calculator echoes the numbers as you type them). Additionally, the conversions should happen in real-time as the user types. In the example below we see that the number 1 is also immediately displayed as the “to” value under the right wheel. In this case both values are the same, as the “from” and “to” units are the same.

After Pressing 1

After Pressing 1

Here the user presses the number 2 which is immediately echoed to the right side of the “form” label to form the number 12. Again, the conversions happen in real-time as soon as the user presses the button. Since both wheels are still the same, we still have 12 on both sides.

After Pressing 2

After Pressing 2

If the user spins and releases one of the wheels, immediately upon releasing the wheel, the “to” value should be immediately recalculated and displayed. Here we see that as soon as the left wheel was changed to Kilobytes, the conversion to Bytes immediately happened and the “to” value was updated to the correct value.

After Sliding Left Wheel to Kilobyte

After Sliding Left Wheel to Kilobyte

A more interesting example of calculations happening in real-time is shown below. As the user presses “.” then “5”, the “to” values are immediately computed and updated.

After Pressing .5

After Pressing .5

If the user presses the delete key the values are immediately removed from the right side of the “from” label — one removal for each delete press. Just like when adding digits, when we remove digits from the “from” value, we should perform real-time conversions against the changing value and update the “to” value accordingly.

After Pressing Delete Twice

After Pressing Delete Twice

The following screen simply shows that the “to” value need not be a whole number as shown in the previous screen shots.

After Sliding Right Wheel to Megabyte

After Sliding Right Wheel to Megabyte

If the user selects a different segment in the control at the top of the app, the wheels of the picker should switch over to the appropriate category and contain the corresponding labels. The “from” value should be preserved and conversion should happen immediately upon selecting the new segment.

After Switching to Temperature

After Switching to Temperature

In the screen shot below, the value has been deleted out and a new value entered. Again, conversions happen as the user manipulates the “from” value.

After Deleting and Re-Entering a New Value

After Deleting and Re-Entering a New Value

Below the left wheel has been spun, conversions have automatically happened between the new “from” and “to” units.

After Sliding Left Wheel to Fahrenheit

After Sliding Left Wheel to Fahrenheit

A spin of the right wheel. The “to” value is updated immediately after releasing the wheel.

After Sliding Right Wheel to Kelvin

After Sliding Right Wheel to Kelvin

Error Handling

Since we’re providing the input by the way of our own buttons, we know exactly what data can be entered. However, there’s still some error checking to be done. Your app should not allow the user to press the “.” button more than once and end up with a string like “”.

Conversion Requirements

At a minimum you need to provide options for converting between Data and Temperature.

For Data, you should at a minimum support converting between Byte, Kilobyte, Megabyte and Gigabytes. Yes, I know that my calculations using 210 are now technically called Kibibytes and the like — call me old fashioned. Feel free to follow in my footsteps, or choose to implement it as 103, or use the [KMG]ibibytes notation — your choice.

For Temperature, you should at a minimum support converting between Celsius, Fahrenheit and Kelvin. Wikipedia’s Temperature Conversion Formulas page provides the formulas for these conversions.

Feel free to add additional categories and units if you wish.


The first thing I’d probably do is to print out one of the images of the UI from this assignment and start to think about and identify…

  • Where do you need outlets?
  • Where do you not need outlets?
  • What instance variables you will need?
  • What action methods do you need?
  • Which of the action methods forms are you using (and thus what’s getting passed in)?
  • What interactions call which action methods?
  • Will all of the interactions behave as described?

Aside from the documentation for the relevant UI, delegate and dataSource classes, I also found NSDecimalNumber useful in my implementation. You will also want to take a good look at the UIPickerView docs to figure out how to reload the wheel values when switching between categories.

Additional Ideas

The following items are provided as thoughts as to how you might extend or improve the project beyond the basic requirements. You are not required to implement any of these.

  • Try out alternate color combinations — just don’t make my eyes bleed
  • Feel free to play with the layout and style of elements — just be sure that things are neatly aligned and that there is at least some justifiable method to your madness
  • Add images to the app if you think it will improve the look and feel of the application
  • I’m open to using alternate input/display mechanisms — just send me an email to tell me what you’re thinking and I’ll let you know if it is acceptable


Your projects will be graded on the following criteria:

  • Correctness of application
  • Appearance of application
  • Adherence to Objective-C and iPhone coding conventions
  • Neatly formatted and indented code
  • Well documented header files
  • Absence of significant performance issues
  • Absence of memory leaks


Like the previous assignment, you are required to submit a zip file of your project directory. Be sure to manually remove the build directory before zipping things up.

To submit the assignment, open up a terminal, navigate to your zip file then issue the command:

submit cs491i assignment3

If developing on your own Mac, you’ll need to transfer the file into your GL account (via SCP), then SSH into GL and issue the submit command.


Leave a Reply

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

You are commenting using your 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: