TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Mar 2016 |
SPMSupports SPM | ✗ |
Maintained by Vladimir Konev.
SwiftyDefaults provides accessing to NSUserDefaults using property.
SwiftyDefaults is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SwiftyDefaults"
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))
Vladimir Konev, KoNEW
SwiftyDefaults is available under the MIT license. See the LICENSE file for more info.
Based on fork of SwiftDefaults due to lack of response to Pull Requests
Need help with proper configuration of Travis CI - you are welcome to send pull request.