blob: 9c12727cfdb06e1b8d1a468054133029c8ef5e87 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
//
// ESUserDefaults.swift
// SmartDeviceLink-iOS
//
// Copyright © 2017 smartdevicelink. All rights reserved.
//
import UIKit
class AppUserDefaults {
struct Keys {
static let ipAddress = "ipAddress"
static let port = "port"
static let lastUsedSegment = "lastUsedSegment"
}
static let shared = AppUserDefaults()
static func setDefaults() {
var defaults: [String : Any] = [:]
defaults[Keys.ipAddress] = String()
defaults[Keys.port] = String()
defaults[Keys.lastUsedSegment] = 0
UserDefaults.standard.register(defaults: defaults)
}
var ipAddress: String? {
get {
return UserDefaults.standard.string(forKey: Keys.ipAddress)
}
set {
UserDefaults.standard.set(newValue!, forKey: Keys.ipAddress)
}
}
var port: String? {
get {
return UserDefaults.standard.string(forKey: Keys.port)
}
set {
UserDefaults.standard.setValue(newValue!, forKeyPath: Keys.port)
}
}
var lastUsedSegment: Int {
get {
return UserDefaults.standard.integer(forKey: Keys.lastUsedSegment)
}
set {
UserDefaults.standard.set(newValue, forKey: Keys.lastUsedSegment)
}
}
}
|