From 20f399eaa6aa08c10db5b7dc58ee86924f30437a Mon Sep 17 00:00:00 2001 From: YOUR NAME Date: Sun, 8 May 2016 21:38:20 -0400 Subject: [PATCH] Closed #1 --- RPI Tours/.DS_Store | Bin 8196 -> 8196 bytes .../RPI Tours/SettingsViewController.swift | 14 ++++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RPI Tours/.DS_Store b/RPI Tours/.DS_Store index aa13ff42dd6e12df5f7dd20ca4c407c0ea7897f2..43fa8fdfd9900251b60fdfc799d72d39e8b07e8c 100644 GIT binary patch delta 52 wcmZp1XmOa}&nUAoU^hRb%w`?|epW_-$@fI`HXjppWSZDevzc8&1XZXK0I1;*d;kCd delta 122 zcmZp1XmOa}&nUMsU^hRb+-4pDepW`U$@fI`_;T}ITvAF)k{K8-`&boDz9V7)6iPu8 S+UzCj$h4VVLWERZc1!?G87E!< diff --git a/RPI Tours/RPI Tours/SettingsViewController.swift b/RPI Tours/RPI Tours/SettingsViewController.swift index 2491e39..16ec8a3 100644 --- a/RPI Tours/RPI Tours/SettingsViewController.swift +++ b/RPI Tours/RPI Tours/SettingsViewController.swift @@ -9,7 +9,8 @@ import UIKit class SettingsViewController: UITableViewController { - + let defaults = NSUserDefaults.standardUserDefaults() + //MARK: IBOutlets @@ -22,11 +23,10 @@ class SettingsViewController: UITableViewController { @IBAction func triggeredSave(sender: AnyObject) { //Load the store - let defaults = NSUserDefaults.standardUserDefaults() //Set the setting - defaults.setObject(measurementTypeSelector.titleForSegmentAtIndex(measurementTypeSelector.selectedSegmentIndex), forKey: "system") - + self.defaults.setObject(measurementTypeSelector.titleForSegmentAtIndex(measurementTypeSelector.selectedSegmentIndex), forKey: "system") + self.defaults.setObject(measurementTypeSelector.selectedSegmentIndex, forKey: "savedIndex") //Prompt the user with an alert let alert = UIAlertController(title: "System", message: "Settings Saved!", preferredStyle: .Alert) @@ -42,6 +42,12 @@ class SettingsViewController: UITableViewController { //MARK: System Functions override func viewDidLoad() { + + if self.defaults.objectForKey("savedIndex") != nil{ + + self.measurementTypeSelector.selectedSegmentIndex = ((self.defaults.objectForKey("savedIndex")) as? Int)! + } + super.viewDidLoad()