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 ofProject
instances) - Add it to the window's
rootViewController
inside of a navigation controller
###Step 2: Setting up a tableViewDatasource
- Create a new datasource object (
ListTableViewDatasource
subclass of NSObject) - Add the UITableViewDatasource protocol required methods
- Add a
dataSource
property to your list viewcontroller (strong) - Initialize the
dataSource
in the init method - Add a
tableView
property toListViewController
- Initialize the
tableView
and add it to the viewcontroller's view - Set the datasource of
tableView
to yourdataSource
property
###Step 3: Create a model and model controller See "Entries" for a sample project
-
Create a
Project
class with necessary properties- Each
Project
instance 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
ProjectController
singleton class (add the instancetype method)- The
ProjectController
should hold an array ofProject
instances - You'll need an
AddProject:
andRemoveProject:
method
- The
-
You'll need methods that convert the objects (
Project
andEntry
) to and from dictionaries- (This allows you to store the model in NSUserDefaults)
- Don't forget to implement storing of
Projects
to NSUserDefaults (loadFromDefaults, syncronize) -Look back at "Day-X" for example
-
Now you can use the
ProjectController
for the row count and row value for thetableView
- Use the
title
Property of Project for the cell label
- Use the
###Step 4: Add a DetailViewController
(Project
instance detail)
- Create a
DetailViewController
with an XIB file - Add a
titleTextField
for the title - Add a
timeLabel
to show the total time - Add a
tableView
to 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
titleTextField
as 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 (
DetailTableViewDatasource
subclass of NSObject) - Add the UITableViewDataSource protocol required methods
- Add a
dataSource
property to yourDetailViewController
(strong) - Initialize the
dataSource
in the init method - Set the
self.tableView.dataSource
to yourdataSource
property
###Step 7: Show a list of entries
- Add a public
Project
property to theDetailViewController
- In the didSelectRow method in the
ListViewController
set theDetailViewController
'sProject
property as theproject
in theProjectController
's project list at the index selected - Add a public
Project
property to theDetailTableViewDatasource
- In the viewDidLoad method of the
DetailViewController
set thedataSource
'sproject
property toself.property
- NumberOfRows should be equal to number of entries
- Set the cell's
textLabel.text
to 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
currentEntry
private property ofProject
- In that method create a new
- Add a method
endCurrentEntry
- In that method set the end time of
currentEntry
to 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
CustomEntryViewController
with an XIB file - Add a public
Project
property 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
cancel
andsave
- Add date pickers and title labels
- Add two date pickers and wire them up to
startDatePicker
andendDatePicker
IBOutlet properties - Add two labels
startDateLabel
andendDateLabel
above 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
save
method create a newEntry
and set the start and end times from the picker views - In both the
save
andcancel
method call "dismissViewController" - In the add method of the
DetailViewController
, instantiate aCustomEntryViewController
, set theproject
property, 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
entries
and append the times to the string) - Set the message string as the messageBody of the viewController
- Call presentViewController on the mailComposeViewController