GenericLocalPersistence
GenericLocalPersistence is a clean and easy-to-use code that is useful for integrating local storage like UserDefaults, PList, Keychain.
Install / Use
/learn @Mindinventory/GenericLocalPersistenceREADME
GenericLocalPersistence
GenericLocalPersistence is a clean and easy-to-use code that is useful for integrating local storage like,
- UserDefaults
- PList
- Keychain
Read more from MEDIUM
Installation
From CocoaPods First, add the following line to your Podfile
pod install 'GenericLocalPersistence', '~> 0.0.1’
pod 'GenericLocalPersistence', :git => 'https://github.com/Riddhi-mi/GenericLocalPersistence.git'
Usage of UserDefault
import GenericLocalPersistence
Set & Get value from User Default
DefaultManager().saveValueInDefault(value: "TestValue", using: "TestKey")
let valueFetch:String = DefaultManager().getValue("TestKey") ?? ""
Usage of Plist
import GenericLocalPersistence
Set & Get value from plist file
Replace "userDetails" with custom name for creating plist file to store data
private let managerPlist = plistManager(named: "userDetails")
managerPlist?.saveDatatoPlist(value: "TestString Value", using: "TestKey")
let stringValue :String = managerPlist?.getDictionary(key: "TestKey") ?? ""
Usage of KeyChain
import GenericLocalPersistence
Set & Get value from KeyChain file
Store password value
let passWordString = textPassword?.text?.data(using: .utf8, allowLossyConversion: false) ?? Data()
let passwordStatus = KeyChainManager()?.save(key: "com.appBundleID.password", data: passWordString)
//Retrive data
if let receivedData = KeyChainManager()?.load(key: "com.appBundleID.password") {
let data = String(decoding: receivedData, as: UTF8.self)
print("result: ", data)
}
Store username value
let userNameString = textName?.text?.data(using: .utf8, allowLossyConversion: false) ?? Data()
let emailStatus = KeyChainManager()?.save(key: "com.appBundleID.email", data: userNameString)
//Retrive data
if let data = KeyChainManager()?.load(key: "com.appBundleID.email") {
let data = String(decoding: data, as: UTF8.self)
print("result: ", data)
}
NOTE
Replace "com.appBundleID" with your project bundleID for KeyChain integration
Define the dataType in which you want to fetch the value and that’s the way you can get the stored value.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
GenericLocalPersistence is MIT-licensed.
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
