Skip to content

Commit

Permalink
Fix crash when no data exists
Browse files Browse the repository at this point in the history
  • Loading branch information
marianomike committed Apr 3, 2017
1 parent b5e746b commit 111ddfd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion MyLastRun/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>2</string>
<string>3</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
30 changes: 24 additions & 6 deletions MyLastRun/SummaryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class SummaryViewController: UIViewController, UITextFieldDelegate, UIPickerView
var typeChoice:String! = ""
var summaryDate:String! = ""
var summaryDuration:String! = "00:00:00"
var summaryPace:String! = "00:00:00"
var summaryPace:String! = "00:00"
var parentVC:ViewController!
var totalDistance:Double = 0
var totalDistance:Double = 0.0

let monthFormatter = DateFormatter()
let formatMonth = "MMM"
Expand Down Expand Up @@ -79,7 +79,7 @@ class SummaryViewController: UIViewController, UITextFieldDelegate, UIPickerView

override func viewDidLoad() {
super.viewDidLoad()
self.updateLabels()
//self.updateLabels()

// Assign Tags to pickers
picker.tag = 1
Expand Down Expand Up @@ -166,9 +166,27 @@ class SummaryViewController: UIViewController, UITextFieldDelegate, UIPickerView
//print("Passed from parent: \(typeChoice)")
SummaryCategory.text = typeChoice
SummaryCategoryInput.text = summaryDate
TotalDurationInput.text = summaryDuration
AveragePaceInput.text = summaryPace
TotalDistanceInput.text = String(totalDistance)
if(summaryDuration == "00:00:00"){
TotalDurationInput.text = nil
}else{
TotalDurationInput.text = summaryDuration
}

if(summaryPace == "00:00"){
AveragePaceInput.text = nil
}else{
AveragePaceInput.text = summaryPace
}

if(totalDistance == 0.0){
TotalDistanceInput.text = nil
}else{
TotalDistanceInput.text = String(totalDistance)
}

//reset to miles
picker.selectRow(0, inComponent: 0, animated: true)
TotalMetricInput.text = "Miles"
}

func milesToKilometers(speedInMPH:Double) ->Double {
Expand Down
8 changes: 5 additions & 3 deletions MyLastRun/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class ViewController: UIViewController, UITextFieldDelegate, UIImagePickerContro
var showStats:Bool! = true
var showSummaryStats:Bool! = true
var typeChoice:String! = "Single"
var totalMilesMonth:Double = 0
var totalMilesYear:Double = 0
var totalMilesMonth:Double = 0.0
var totalMilesYear:Double = 0.0
var totalDurationMonth:TimeInterval = 0
var totalDurationYear:TimeInterval = 0
var curYear:String = "2017"
Expand Down Expand Up @@ -295,8 +295,9 @@ class ViewController: UIViewController, UITextFieldDelegate, UIImagePickerContro
summaryVC.summaryPace = paceYear
}else if(type == "Month"){
summaryVC.totalDistance = totalMilesMonth
summaryVC.summaryDate = curMonth
summaryVC.summaryDuration = durationMonth
summaryVC.summaryDate = curMonth

summaryVC.summaryPace = paceMonth
}
summaryVC.updateLabels()
Expand Down Expand Up @@ -797,6 +798,7 @@ class ViewController: UIViewController, UITextFieldDelegate, UIImagePickerContro
MetricsInput.text = metricsOptions[row]

if(metricsOptions[row] == "Miles"){
//if()
updateToMiles()
}else if(metricsOptions[row] == "Kilometers"){
updateToKM()
Expand Down

0 comments on commit 111ddfd

Please sign in to comment.