All Projects → batuhansk → UserDefault

batuhansk / UserDefault

Licence: other
The simplest way of using the UserDefaults with @propertyWrapper.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to UserDefault

Litfs
A FUSE file system in Go extended with persistent file storage
Stars: ✭ 116 (+582.35%)
Mutual labels:  persistence
Lucid
High performance and distributed KV store w/ REST API. 🦀
Stars: ✭ 171 (+905.88%)
Mutual labels:  persistence
Storagekit
Your Data Storage Troubleshooter 🛠
Stars: ✭ 225 (+1223.53%)
Mutual labels:  persistence
Vuex Localstorage
Persist Vuex state with expires by localStorage or some else storage.
Stars: ✭ 129 (+658.82%)
Mutual labels:  persistence
Justpersist
JustPersist is the easiest and safest way to do persistence on iOS with Core Data support out of the box. It also allows you to migrate to any other persistence framework with minimal effort.
Stars: ✭ 157 (+823.53%)
Mutual labels:  persistence
Modernavplayer
ModernAVPlayer is a persistence AVPlayer wrapper
Stars: ✭ 179 (+952.94%)
Mutual labels:  persistence
Jafar
🌟!(Just another form application renderer)
Stars: ✭ 107 (+529.41%)
Mutual labels:  persistence
client-side-databases
An implementation of the exact same app in Firestore, AWS Datastore, PouchDB, RxDB and WatermelonDB
Stars: ✭ 787 (+4529.41%)
Mutual labels:  persistence
Technowlogger
TechNowLogger is Windows/Linux Keylogger Generator which sends key-logs via email with other juicy target info
Stars: ✭ 172 (+911.76%)
Mutual labels:  persistence
Fancytree
JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading
Stars: ✭ 2,398 (+14005.88%)
Mutual labels:  persistence
Ardb
A redis protocol compatible nosql, it support multiple storage engines as backend like Google's LevelDB, Facebook's RocksDB, OpenLDAP's LMDB, PerconaFT, WiredTiger, ForestDB.
Stars: ✭ 1,707 (+9941.18%)
Mutual labels:  persistence
Fluentdispatch
🌊 .NET Standard 2.1 framework which makes easy to scaffold distributed systems and dispatch incoming load into units of work in a deterministic way.
Stars: ✭ 152 (+794.12%)
Mutual labels:  persistence
Hydrated bloc
An extension to the bloc state management library which automatically persists and restores bloc states.
Stars: ✭ 181 (+964.71%)
Mutual labels:  persistence
Persistentstreamplayer
Stream audio over http, and persist the data to a local file while buffering
Stars: ✭ 120 (+605.88%)
Mutual labels:  persistence
Skopelos
A minimalistic, thread safe, non-boilerplate and super easy to use version of Active Record on Core Data. Simply all you need for doing Core Data. Swift flavour.
Stars: ✭ 231 (+1258.82%)
Mutual labels:  persistence
Kripton
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Stars: ✭ 110 (+547.06%)
Mutual labels:  persistence
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (+935.29%)
Mutual labels:  persistence
mst-persist
Persist and hydrate MobX-state-tree stores (in < 100 LoC)
Stars: ✭ 75 (+341.18%)
Mutual labels:  persistence
Data
ATK Data - Data Access Framework for high-latency databases (Cloud SQL/NoSQL).
Stars: ✭ 243 (+1329.41%)
Mutual labels:  persistence
Technowhorse
TechNowHorse is a RAT (Remote Administrator Trojan) Generator for Windows/Linux systems written in Python 3.
Stars: ✭ 189 (+1011.76%)
Mutual labels:  persistence

UserDefault

UserDefault wrapper enables you to use UserDefaults in the simplest way with the power of @propertyWrapper.

Primitive types of Swift which conforms Codable protocol internally are supported. (String, Int, Float, Double, Data, Bool, Date, URL)

Installation

Swift Package Manager:

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/strawb3rryx7/UserDefault.git", from: "master")
]

Manually

Just drag the UserDefault.swift file into your project directory. It's all done.

Usage

import UserDefault

struct Defaults {
    @UserDefault("is_discount_provided", defaultValue: false)
    static var isDiscountProvided: Bool
}

How to Modify?

Well, that's pretty simple. You only have to access the variable through the Defaults struct, and set it the value.

Defaults.isDiscountProvided = true

In addition, Custom models which conforms Codable protocol can be stored too.

Custom models

struct User: Codable {
    let firstName: String
    let lastName: String
}

struct Defaults {
    @UserDefault("default_user")
    static var defaultUser: User?
}

You can specify any UserDefaults suite for each one. If you want to store on standard suite, no needed to specify it. Default is UserDefaults.standard.

Usage of custom UserDefaults suite

struct Contact: Codable {
    let firstName: String
    let lastName: String
    let phoneNumber: String
}

private let appSuite = UserDefaults(suiteName: "com.strawb3rryx7.userdefault.appsuite")!
private let customSuite = UserDefaults(suiteName: "com.strawb3rryx7.userdefault.customsuite")!

struct Defaults {
    @UserDefault("primary_contact", suite: appSuite)
    static var primaryContact: Contact?
  
    @UserDefault("has_seen_purchase_screen", defaultValue: false, suite: customSuite)
    static var hasSeenPurchaseScreen: Bool
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].