Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions DebuggingAndProfiling/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ struct ContentView_Previews: PreviewProvider {
ContentView()
}
}



// Converting f to c required a variable change from var to let.

//OG - var cel = (fah + 32) * 5 / 9
//NEW - let cel = (fah - 32) * 5 / 9
//OG - var fah = (cel * 5 / 9 ) + 32
//NEW - let fah = (cel * 9 / 5) + 32
//2. Foreground in OccassionalUpdate redrawn 7 times, Stress test continues to grow while in foreground
//3. //OccasionalUpdate shows a hang after button click, Stress test runtime is about 28ms per run

8 changes: 6 additions & 2 deletions DebuggingAndProfiling/DebugThisCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ struct DebugThisCode: View {
print("Fah changed to \(fahrenheitTemp)")
if let fah = Double(fahrenheitTemp) {
print("Value is \(fah)")
var cel = (fah + 32) * 5 / 9

//Variable 'cel' was never mutated; consider changing to 'let' constant

let cel = (fah + 32) * 5 / 9
celsiusTemp = String(cel)
} else {
print("Not a valid number")
Expand All @@ -42,7 +45,8 @@ struct DebugThisCode: View {
TextField("Temperature in Celsius", text: $celsiusTemp)
Button(action: {
if let cel = Double(celsiusTemp) {
var fah = (cel * 5 / 9 ) + 32
// Variable 'fah' was never mutated; consider changing to 'let' constant
let fah = (cel * 5 / 9 ) + 32
fahrenheitTemp = String(fah)
} else {
print("Not a valid number")
Expand Down