Swiftpack.co - Package - DuckDeck/GrandStore

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请直接和我联系3421902@qq.com, 我会乐于帮你解决

Github

link
Stars: 4

Dependencies

Used By

Total: 0

Releases

update to swift 4.2 - 2018-10-10 02:47:33

Update to swift 3 version - 2016-10-13 09:27:09

Add Arrary Operate - 2016-07-01 01:34:22

add new feature--- temp save in the memory - 2016-03-03 08:32:15

Fix can not store issue - 2016-02-24 02:23:47

Fix the Class is private class and set it public - 2016-02-02 02:59:30

Firse Release - 2016-01-26 01:54:23