An iOS app with time tracking
###Step 1: Create the list view controller
- Either in Pomodoro or in a new app create a new
ListViewController(list ofProjectinstances) - Add it to the window's
rootViewControllerinside of a navigation controller
###Step 2: Setting up a tableViewDatasource
- Create a new datasource object (
ListTableViewDatasourcesubclass of NSObject) - Add the UITableViewDatasource protocol required methods
- Add a
dataSourceproperty to your list viewcontroller (strong) - Initialize the
dataSourcein the init method - Add a
tableViewproperty toListViewController - Initialize the
tableViewand add it to the viewcontroller's view - Set the datasource of
tableViewto yourdataSourceproperty
###Step 3: Create a model and model controller See "Entries" for a sample project
-
Create a
Projectclass with necessary properties- Each
Projectinstance should hold an array of ```Entries`` - You'll need an
AddEntry:andRemoveEntry:method
- Each
-
Create an
Entry(word periods) class with necessary properties -
Create a
ProjectControllersingleton class (add the instancetype method)- The
ProjectControllershould hold an array ofProjectinstances - You'll need an
AddProject:andRemoveProject:method
- The
-
You'll need methods that convert the objects (
ProjectandEntry) to and from dictionaries- (This allows you to store the model in NSUserDefaults)
- Don't forget to implement storing of
Projectsto NSUserDefaults (loadFromDefaults, syncronize) -Look back at "Day-X" for example
-
Now you can use the
ProjectControllerfor the row count and row value for thetableView- Use the
titleProperty of Project for the cell label
- Use the
###Step 4: Add a DetailViewController (Project instance detail)
- Create a
DetailViewControllerwith an XIB file - Add a
titleTextFieldfor the title - Add a
timeLabelto show the total time - Add a
tableViewto show the list ofEntries - Add a UIToolBar with an Add, Check In, Check Out, and Report button
- Add those objects as properties on the view
- Wire them up
- Add a method for each button
- Add
- Clock In
- Clock Out
- Report
###Step 5: Add UITextFieldDelegate methods to capture the title
- Add the textFieldShould return method to dismiss the Keyboard
- Add a textFieldShouldEndEditing method to store the text of the
titleTextFieldas theproject.title - Wire files owner as the delegate of the text field in the XIB file
###Step 6: Add a datasource for the tableview
- Create a new datasource object (
DetailTableViewDatasourcesubclass of NSObject) - Add the UITableViewDataSource protocol required methods
- Add a
dataSourceproperty to yourDetailViewController(strong) - Initialize the
dataSourcein the init method - Set the
self.tableView.dataSourceto yourdataSourceproperty
###Step 7: Show a list of entries
- Add a public
Projectproperty to theDetailViewController - In the didSelectRow method in the
ListViewControllerset theDetailViewController'sProjectproperty as theprojectin theProjectController's project list at the index selected - Add a public
Projectproperty to theDetailTableViewDatasource - In the viewDidLoad method of the
DetailViewControllerset thedataSource'sprojectproperty toself.property - NumberOfRows should be equal to number of entries
- Set the cell's
textLabel.textto theentry's start and end date- Feel free to format them if you'd like it to look pretty: http://gtiapps.com/?p=1086
###Step 8: Add a Clock In and Clock Out method to the Project object
- Add a method
startNewEntry- In that method create a new
Entry, and set the start time to now - Store that entry as a
currentEntryprivate property ofProject
- In that method create a new
- Add a method
endCurrentEntry- In that method set the end time of
currentEntryto now
- In that method set the end time of
- Call those methods when the user selects clockIn or clockOut BarButtonItems on your UIToolBar
- Be sure to reload the
tableView's data
- Be sure to reload the
###Step 9: Create a custom entry screen
- Create a new
CustomEntryViewControllerwith an XIB file - Add a public
Projectproperty to yourCustomEntryViewController - Add a fake navigation bar
- Add a cancel and save button and a title
- Wire up the cancel and save buttons to IBActions
cancelandsave - Add date pickers and title labels
- Add two date pickers and wire them up to
startDatePickerandendDatePickerIBOutlet properties - Add two labels
startDateLabelandendDateLabelabove the pickers to show which is which (they don't need to be wired)
- Add two date pickers and wire them up to
- In the
savemethod create a newEntryand set the start and end times from the picker views - In both the
saveandcancelmethod call "dismissViewController" - In the add method of the
DetailViewController, instantiate aCustomEntryViewController, set theprojectproperty, and call "presentViewController" to show it
###Step 10: Add reporting
- Add the MessageUI library to your project
- In the report method, instantiate an MFMailComposeViewController
- Create a string of all of the entry times (loop through the
entriesand append the times to the string) - Set the message string as the messageBody of the viewController
- Call presentViewController on the mailComposeViewController