SwiftyUserDefaults-封装系统本地化的框架推荐

 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>("age")
28 }

 

详见  https://github.com/radex/SwiftyUserDefaults

posted @ 2017-01-14 18:32  Dast1  阅读(672)  评论(0编辑  收藏  举报