Latest1.0.0
Homepagehttps://github.com/romankl/KeyValue-swift
LicenseMIT
Platformsios 8.0, requires ARC
DependenciesRealmSwift
Authors

[![CI Status](http://img.shields.io/travis/Roman Klauke/ROKKeyValue.svg?style=flat)](https://travis-ci.org/Roman Klauke/ROKKeyValue)
Version
License
Platform

Usage

Import the framework in your file using import ROKKeyValue to work with ROKKeyValue.

Each method allows you to provide an alternative Realm in which the keys should
be saved.

Insert or updates of keys

ROKKeyValue.put("test", bool: false)
ROKKeyValue.put("date", date: NSDate())
ROKKeyValue.put("double", double: 1.5)
ROKKeyValue.put("float", float: 9.12)
ROKKeyValue.put("int", int: 1)
ROKKeyValue.put("string", string: "My String Key")

If one of those keys already exists, ROKKeyValue will simply update the
existing key with the new value.

Get keys

ROKKeyValue.getDouble("Double")
ROKKeyValue.getDouble("Double", defaultValue: 1.1)
ROKKeyValue.getFloat("Float")
ROKKeyValue.getFloat("Float", defaultValue: 1.1)
ROKKeyValue.getInt("Int")
ROKKeyValue.getInt("Int", defaultValue: 1)
ROKKeyValue.getBool("Bool")
ROKKeyValue.getBool("Bool", defaultValue: false)
ROKKeyValue.getDate("Date")
ROKKeyValue.getDate("keDatey", defaultValue: NSDate())
ROKKeyValue.getString("String")
ROKKeyValue.getString("String", defaultValue: "")

Using ROKKeyValue.getBool("Bool", defaultValue: false) will return the
specified defaultValue if the value does not exist. Calling
ROKKeyValue.getBool("Bool") would return the corredsponding zero or empty
value for the chosen data type.

Removing keys

ROKKeyValue.remove("key")

Util

Get the total number of keys in the given realm:

ROKKeyValue.entryCount()

Get the "raw" key as an Object:

ROKKeyValue.getRaw("test")

Requirements

ROKKeyValue depends on Realm and iOS 8.0. It’s currently only available for
Swift 1.2.
A Swift 2.0 branch is planed.

Installation

ROKKeyValue is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "ROKKeyValue"

Author

Roman Klauke, [email protected]

License

ROKKeyValue is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ROKKeyValue",
    "version": "1.0.0",
    "summary": "Store Key/Value pairs in your Realm.",
    "description": "Use Realm as an alternative to NSUserDefaults. Store different types in thenRealm file.",
    "homepage": "https://github.com/romankl/KeyValue-swift",
    "license": "MIT",
    "authors": {
        "Roman Klauke": "[email protected]"
    },
    "source": {
        "git": "https://github.com/romankl/KeyValue-swift.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "ROKKeyValue": [
            "Pod/Assets/*.png"
        ]
    },
    "dependencies": {
        "RealmSwift": []
    }
}

Pin It on Pinterest

Share This