UserDefaults alternatives and similar libraries
Based on the "Database" category.
Alternatively, view UserDefaults alternatives based on common mentions on social networks and blogs.
-
Realm
The alternative to CoreData and SQLite: Simple, modern and fast. -
MMKV
An efficient, small mobile key-value storage framework developed by WeChat. Works on iOS, Android, macOS and Windows. -
WCDB
WCDB is an efficient, complete, easy-to-use mobile database framework for iOS, macOS. -
SQLite.swift
A type-safe, Swift-language layer over SQLite3. -
YapDatabase
YapDatabase is an extensible database for iOS & Mac. -
ParseAlternatives
A collaborative list of Parse alternative backend service providers. -
SugarRecord
Data persistence management library written in Swift 2.0 -
Couchbase Mobile
Couchbase document store for mobile with cloud sync. -
FCModel
An alternative to Core Data for people who like having direct SQL access. -
CTPersistance
iOS Database Persistence Layer with SQLite, your next Persistence Layer! -
MongoKitten
A pure Swift MongoDB client implementation with support for embedded databases. -
Prephirences
Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state. -
Unrealm
Unrealm enables you to easily store Swift native Classes, Structs and Enums into Realm. -
RealmIncrementalStore
Realm-powered Core Data persistent store. -
PredicateEditor
A visual editor for dynamically creating NSPredicates to query data in your iOS app. -
UserDefaultsStore
An easy and very light way to store and retrieve -reasonable amount- of Codable objects, in a couple lines of code. -
Palau
NSUserDefaults with Wings! Custom Validation, Swift Generics. -
ObjectBox
ObjectBox is a superfast, light-weight object persistence framework. -
Nora
Nora is a Firebase abstraction layer for working with FirebaseDatabase and FirebaseStorage. -
realm-cocoa-converter
A library that provides the ability to import/export Realm files from a variety of data container formats. -
MySQL
A Swift wrapper around the MySQL client library, enabling access to MySQL servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
SecureDefaults
A lightweight wrapper over UserDefaults/NSUserDefaults with an extra AES-256 encryption layer. -
RealmGeoQueries
RealmGeoQueries simplifies spatial queries with Realm Cocoa. In the absence of and official functions, this library provide the possibility to do proximity search. -
PersistentStorageSerializable
Swift library that makes easier to serialize the user's preferences (app's settings) with system User Defaults or Property List file on disk. -
PersistenceKit
Store and retrieve Codable objects to various persistence layers, in a couple lines of code. -
YapDatabaseExtensions
YapDatabase extensions for use with Swift -
TypedDefaults
TypedDefaults is a utility library to type-safely use NSUserDefaults. -
MongoDB
A Swift wrapper around the mongo-c client library, enabling access to MongoDB servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
PostgreSQL
A Swift wrapper around the libpq client library, enabling access to PostgreSQL servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
FileMaker
A Swift wrapper around the FileMaker XML Web publishing interface, enabling access to FileMaker servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
SQLite
A Swift wrapper around the SQLite 3 client library, enabling access to SQLite servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
Storez
Safe, statically-typed, store-agnostic key-value storage (with namespace support). -
Redis
A Swift wrapper around the Redis client library, enabling access to Redis. Part of the Perfect project, but stand-alone. SPM and Swift 3 support.
Scout APM - Leading-edge performance monitoring starting at $39/month
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of UserDefaults or a related project?
README
[็ฎไฝไธญๆ](README.zh-CN.md)
DefaultsKit leverages Swift 4's powerful Codable capabilities to provide a Simple and Strongly Typed wrapper on top of UserDefaults. It uses less than 70 lines of code to acomplish this.
Installation >> instructions
<<
Usage
Instantiate, or get a shared
instance of Defaults
let defaults = Defaults() // or Defaults.shared
Then:
// Define a key
let key = Key<String>("someKey")
// Set a value
defaults.set("Codable FTW ๐", for: key)
// Read the value back
defaults.get(for: key) // Output: Codable FTW ๐
Check if a key has a value:
if defaults.has(key) {
// Do your thing
}
If you just need to know that a key/value pair exists, without actually using the value, use the
has()
method instead of the optionalget(for:key)
. For complex objects it will prevent any unnecessary deserialization.
Implicit Member Expression
You can find a convenience wrapper for your keys by extending DefaultsKey
. This allows you use Implicit Member Expression:
// Extend with a custom key
extension DefaultsKey {
static let someKey = Key<String>("someKey")
}
// Then use it like this
defaults.set("Some key", for: .someKey)
defaults.get(for: .someKey) // Output: Some key
Complex objects
To store a complex object just conform to the Codable protocol:
struct Person: Codable {
let name: String
let age: Int
}
Then:
// Create a key
let key = Key<Person>("personKey")
// Get an instance of your Codable conforming enum, struct or class
let person = Person(name: "Bonnie Greenwell", age: 80)
// Set the value
defaults.set(person, for: key)
And finally:
// Read it back
let person = defaults.get(for: key)
person?.name // Bonnie Greenwell
person?.age // 80
Nested Objects
You can also use nested objects as long as they conform to the Codable
protocol:
enum Pet: String, Codable {
case cat
case dog
}
struct Person: Codable {
let name: String
let pets: [Pet]
}
// Get a Codable conforming instante
let person = Person(name: "Claire", pets: [.cat])
// Set the value
defaults.set(person, for: key)
// And read it back
let person = defaults.get(for: key)
person?.name // Claire
person?.pets.first // cat
License
DefaultsKit is released under the MIT license. See LICENSE for details.
Help Wanted
Review/Translate [README.zh-CN.md](README.zh-CN.md) to Chinese
Chinese is the #1 spoken language in the world and I'd love to have DefaultsKit be more inclusive, unfortunately I don't speak Chinese. If you know chinese, and would like to help out, please see issue #1
Thank you ๐
*Note that all licence references and agreements mentioned in the UserDefaults README section above
are relevant to that project's source code only.