GrandStore 1.1.0

GrandStore 1.1.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2018
SPMSupports SPM

Maintained by DuckDeck.



  • By
  • DuckDeck

GrandStore

GrandStore是一个直观且强大的iOS存储库,他用变量名来保存任何类型

关键特点

  • GrandStore是基于泛型类的,所以它可以存储任何的Object,只要符合了NSCoding协议
  • 可以任意存值和取值
  • 强力的缓存特性
  • 存储的值是可以被观察的,只要你调用了addObserver函数.
  • 清除缓存也相当简单

系统要求

Xcode 8 and iOS 8.0(最新的Swift语法,Swift3) ####请注意,这个类只适用了纯Swift项目,Objc类不能调用这个类 ##安装 如果你使用cocopods, 则pod 'GrandStore' 再安装即可.然后再 pod install
如果你想使用文件,直接拷贝GrandStore.swift到你的项目即可

怎么使用

*请参考以下代码

 var demoText = GrandStore(name: "DemoText", defaultValue: ""), the second para can not be nil, GrandStore must usr it to infer the type.
demoText.Value = "the value you will set" //set the value
let va = demoText.Value //get the value
let stu = GrandStore(name: "student", defaultValue: Student())// Student is a custom cass and it must confirm NSCoding protocal.The set and get process is the same as the DemoText 
var demoCache = GrandStore(name: "CacheTest", defaultValue: "", timeout: 10)//if you want set a value which can expire,just add the timeout para. cache time 
demoCache..setCacheTime(50)// you can change the cache time anytime, or you can set a current GrandStore to cache mode
demoCache.clear()// call the clear() func to clear the cache
stu.addObserver { (observerObject, observerKey, oldValue, newValue) -> Void in
              self.lblStudent?.text = "old:\(oldValue.debugDescription), new:\(newValue.debugDescription)"
        }
        //if you want to observer the value change, just call the addObserver func, and set the block callback
stu.removeObserver() //call the removeObserver() func to remoce the observer

*参考GrandStoreDemo会更好的理解GrandStore怎么使用


add -DDEBUG location

add -DDEBUG location

add -DDEBUG location

和我联系

任何问题或者BUG请直接和我联系[email protected], 我会乐于帮你解决