Swiftpack.co - DuckDeck/GrandStore as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
GrandStore is an intuitionistic and powerful iOS store tool. It use variable name as the store key.
.package(url: "https://github.com/DuckDeck/GrandStore.git", from: "3.1.0")




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


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



 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


add -DDEBUG location

add -DDEBUG location

add -DDEBUG location


任何问题或者BUG请直接和我联系3421902@qq.com, 我会乐于帮你解决


Stars: 4
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

4 weeks ago


Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics