Skip to content

Commit 2eb66f5

Browse files
committed
Fixing 'default' tip when no default set
1 parent de74782 commit 2eb66f5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tips/Utilities.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ private let CACHE_BILL_KEY = "cachedBill"
1616
private let LOCALE_KEY = "locale"
1717
private let cacheExpiryMins = 10.0
1818

19-
private let tipPercentages = [5.0, 10.0, 15.0, 20.0, 25.0]
2019
let defaults = NSUserDefaults.standardUserDefaults()
2120

2221
func getDefaultTip() -> Float {
23-
return defaults.floatForKey(DEFAULT_TIP_KEY)
22+
var tip = defaults.floatForKey(DEFAULT_TIP_KEY)
23+
if tip == 0 {
24+
tip = 15.0
25+
setDefaultTip(tip)
26+
}
27+
return tip
2428
}
2529

2630
func setDefaultTip(tip: Float) {

0 commit comments

Comments
 (0)