iPhone Project 1
Background
- This is the first iPhone app I wrote last year
- There is not a lot of code!!!
- Best way to do this is just copy the code in XCode as needed and follow the simple instructions below about creating the UI in Interface Builder
Requirements
- Provide effective light from the iPhone in Darkness
- On/Off Switch
- No Fade Out/Dim
- See screen below.
- Label is White when torch is on (Yes this is a very simple torch!)
- Label is black when torch is off
- On Application start torch is off
- Off/On button toggles the light
- None required at this stage (OK so my objective C needs to get improved before I start building unit tests first). I promise it will happen …. yeah yeah.
Code (Please Note was built with XCODE 3.0.1)
- iPhone_TorchViewController.h
- iPhone_TorchViewController.m (Important Bits)
#import “iPhone_TorchViewController.h”
1. Option click on the File Owner and drag from the label item to the actual big label on the view.
2. Click on each of the buttons and bring up the button connections. Click on the Touch Up Inside connection and drag that to the File Owner – selecting the button pressed action. Make sure you do this for both buttons.
Issues
- Should make it a bit more funky (FlashLight – Version 2)
- Using the title of the buttons to determine which one pressed is a bit dodgy – will see if we can improve this
Summary
Ok so this was an extremely simple applIcation and no test driven development (Curse you Dom) but was achieved in just over an hour and considering this is my first iPhone app – I am pretty happy. In terms of the process, it was all fairly basic but as we consider this series of Projects you’ll see things get more complex.
Dom
