1 //
2 // ViewController.swift
3 Test4SwiftyUserDefaults
4 6 Copyright © 2017年. All rights reserved.
7 //
8
9 import UIKit
10
11 class ViewController: UIViewController {
12
13 override func viewDidLoad() {
14 super.viewDidLoad()
15 Defaults[.userID] = "lilei";
16 Defaults[.age] = 18
17 Defaults[.age] += 12
18 print(Defaults[.userID])
19 print(Defaults[.age])
20 }
21
22 }
23
24
25 extension DefaultsKeys{
26 static let userID = DefaultsKey<String>(userID)
27 static let age = DefaultsKey<Int>(age28 }