https://github.com/coldgrub1384/objectuserdefaults
An object oriented and clean wrapper UserDefaults.
https://github.com/coldgrub1384/objectuserdefaults
ios macos swift tvos userdefaults watchos
Last synced: about 1 year ago
JSON representation
An object oriented and clean wrapper UserDefaults.
- Host: GitHub
- URL: https://github.com/coldgrub1384/objectuserdefaults
- Owner: ColdGrub1384
- License: mit
- Created: 2018-09-05T23:02:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-25T16:52:08.000Z (over 7 years ago)
- Last Synced: 2024-03-15T04:21:53.808Z (over 2 years ago)
- Topics: ios, macos, swift, tvos, userdefaults, watchos
- Language: Swift
- Homepage: https://coldgrub1384.github.io/ObjectUserDefaults
- Size: 467 KB
- Stars: 16
- Watchers: 8
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ObjectUserDefaults
  [](https://swift.org) [](https://github.com/ColdGrub1384/ObjectUserDefaults/blob/master/LICENSE)
An object oriented `UserDefaults`.
`UserDefaults` uses methods to get values and set values with given keys, but you have to pass keys as parameters each time you want to set or get a value. With `ObjectUserDefaults`, each item in stored in `UserDefaults` is represented by an object and its value can be set and gotten trough that. That's mean that instead of storing keys in constant, you can store direct references to items.
## Usage
```swift
import ObjectUserDefaults
let item = ObjectUserDefaults.standard.item(forKey: "Key") // Creates a reference to the key "Key"
print(item.value) // Prints the value of the key
item.value = true // Sets the value of the key
print(item.boolValue) // Prints the boolean value of the key
```
## Installation
### Cocoapods
`pod 'ObjectUserDefaults'`
### Manual
Copy this repo to yours or add it as submodule, drag the xcode project to your one and embed the framework in your target's info tab.
## Documentation
See the docs [here](https://coldgrub1384.github.io/ObjectUserDefaults)