RealmDefaults 0.4.3

RealmDefaults 0.4.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2016
SPMSupports SPM

Maintained by muukii, muukii0803, muukii.



RealmDefaults

Usage

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

Requirements

Installation

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

pod "RealmDefaults"

Usage

public class RealmDefaults : RealmSwift.Object {

    public class func purge()

    public static func write(@noescape block: (Self) -> Void)

    public class func schemaVersion() -> UInt64

    public class func defaultsName() -> String

    public class func filePath() -> String

    public class func configuration() -> RealmSwift.Realm.Configuration
}

Create subclass of RealmDefaults.

import RealmDefaults

class MyAccount: RealmDefaults {

    dynamic var name: String?
    dynamic var age: Int = 0
    dynamic var phoneNumber: String?

    override class func schemaVersion() -> UInt64 {
        return 3
    }
}

Read & Write

MyAccount.write { account in
    account.name = "muukii"
    account.age = 25
    account.phoneNumber = "080-0000-0000"
}

print(MyAccount.instance.name) // -> muukii
print(MyAccount.instance.age) // 25
print(MyAccount.instance.phoneNumber) // 080-0000-0000

Author

muukii, [email protected]

License

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