Skip to content

SwiftDefaults provides accessing to NSUserDefaults using property.

License

Notifications You must be signed in to change notification settings

shimesaba9/SwiftDefaults

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftDefaults

CI Status Version License Platform

Description

SwiftDefaults provides accessing to NSUserDefaults using property.

import SwiftDefaults

class MyDefaults: SwiftDefaults {
    dynamic var value: String? = "10"
    dynamic var value2: String = "10"
    dynamic var value3: Int = 1
    dynamic var value4: Person? = nil
}

print(MyDefaults().value2)
MyDefaults().value2 = "2"
print(MyDefaults().value2)

print("Stored person instance: \(MyDefaults().value4)")
let p = Person()
p.firstName = "Elvis"
p.lastName = "Presley"
p.age = 42
MyDefaults().value4 = p
print("Stored person instance: \(MyDefaults().value4)")
MyDefaults().value4 = nil
print("Stored nil person: \(MyDefaults().value4)")

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

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

pod "SwiftDefaults"

Author

shimesaba9, @shimesaba43

License

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

About

SwiftDefaults provides accessing to NSUserDefaults using property.

Resources

License

Stars

Watchers

Forks

Packages