Latest 1.0.0
Homepage https://github.com/KoNEW/SwiftyDefaults
License MIT
Platforms ios 8.0, requires ARC
Authors

CI Status
Version
License
Platform

Description

SwiftyDefaults provides accessing to NSUserDefaults using property.

Installation

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

pod "SwiftyDefaults"

Example of usage

import SwiftyDefaults

class MyDefaults: SwiftyDefaults {
    dynamic var value1: String? = nil
    dynamic var value2: String = "Some value"
    dynamic var value3: Int = 1
    dynamic var value4: Person? = nil // Person class conforms to NSCoding procotol
}

let md = MyDefaults()

print("Value1: (md.value1)") // nil
print("Value2: (md.value2)") // "Some value"
print("Value3: (md.value3)") // 1
print("Value4: (md.value4)") // nil

md.value1 = "Some another value"
md.value2 = "Some another value 2"
md.value3 = 10
md.value4 = Person(firstName: "Elvis", lastName: "Presley", age: 42)

print("Value1: (md.value1)") // Optional("Some another value")
print("Value2: (md.value2)") // "Some an0ther value 2"
print("Value3: (md.value3)") // 10
print("Value4: (md.value4)") // Optional(Person=(Optional("Elvis"), Optional("Presley"), 42))

Author

Vladimir Konev, KoNEW

License

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

Original source

Based on fork of SwiftDefaults due to lack of response to Pull Requests

For contributors

Need help with proper configuration of Travis CI – you are welcome to send pull request.

Latest podspec

{
    "name": "SwiftyDefaults",
    "version": "1.0.0",
    "summary": "SwiftyDefaults provides accessing to NSUserDefaults using property.",
    "description": "SwiftyDefaults provides accessing to NSUserDefaults using property.nn```swiftnimport SwiftyDefaultsnnclass MyDefaults: SwiftyDefaults {n    dynamic var value1: String? = niln    dynamic var value2: String = "Some value"n    dynamic var value3: Int = 1n    dynamic var value4: Person? = nil // Person class conforms to NSCoding procotoln}nnlet md = MyDefaults()nnprint("Value1: (md.value1)") // nilnprint("Value2: (md.value2)") // "Some value"nprint("Value3: (md.value3)") // 1nprint("Value4: (md.value4)") // nilnnmd.value1 = "Some another value"nmd.value2 = "Some another value 2"nmd.value3 = 10nmd.value4 = Person(firstName: "Elvis", lastName: "Presley", age: 42)nnprint("Value1: (md.value1)") // Optional("Some another value")nprint("Value2: (md.value2)") // "Some an0ther value 2"nprint("Value3: (md.value3)") // 10nprint("Value4: (md.value4)") // Optional(Person=(Optional("Elvis"), Optional("Presley"), 42))n```",
    "homepage": "https://github.com/KoNEW/SwiftyDefaults",
    "license": "MIT",
    "authors": {
        "Vladimir Konev": "[email protected]"
    },
    "source": {
        "git": "https://github.com/KoNEW/SwiftyDefaults.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*"
}

Pin It on Pinterest

Share This