-
Notifications
You must be signed in to change notification settings - Fork 0
/
settingsViewController.swift
32 lines (28 loc) · 1.1 KB
/
settingsViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// settingsViewController.swift
// tips
//
// Created by Deepak on 8/20/14.
// Copyright (c) 2014 Deepak. All rights reserved.
//
import UIKit
class settingsViewController: UIViewController {
@IBOutlet var tipDefaultControl: UISegmentedControl!
@IBAction func doneSetting(sender: AnyObject) {
dismissViewControllerAnimated(true, completion: nil)
}
@IBAction func defTipChanged(sender: UISegmentedControl) {
var tipPercentageIndex = tipDefaultControl.selectedSegmentIndex;
var defaults = NSUserDefaults.standardUserDefaults();
defaults.setObject(tipPercentageIndex, forKey: "defTipPercentageIndex");
defaults.synchronize();
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
//self.view.backgroundColor = UIColor.lightGrayColor();
//get the default values for tip percentage
var defaults = NSUserDefaults.standardUserDefaults();
var defTipPercentageIndex = defaults.integerForKey("defTipPercentageIndex");
tipDefaultControl.selectedSegmentIndex = defTipPercentageIndex;
}
}