Unrealm enables you to easily store Swift native Classes, Structs and Enums into Realm .
Stop inheriting from Object! Go for Protocol-Oriented programming!
Made with β€οΈ by arturdev
Unrealm supports the following types:
To run the example project, clone the repo, and run pod install
from the Example directory first.
See also Unit Tests.
All you have to do is
Realmable
protocol instead of inheriting from Object
. Conform your Enums to RealmableEnum
protocol.didFinishLaunchingWithOptions
.Realm.registerRealmables(ToDoItem.self)
Thats it! Now you can store your Struct or Class object into Realm as usualy you do with Objc Classes.
@objc dynamic var
. Use just var
or let
RealmOptional<Int>
. Use just Int?
let realm = try! Realm()
var todoItem = realm.object(ofType: ToDoItem.self, forPrimaryKey: "1")
todoItem.text = "Modified text"
try! realm.write {
realm.add(todoItem, update: true) //<- force Realm to update the object
}
Unrealm is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Unrealm'
You can also use Swift Package Manager to add Unrealm as a dependency to your project. In order to do so, use the following URL:
https://github.com/arturdev/Unrealm.git
You need to use "master" branch instead of SPM.
βοΈ If you like what you see, star us on GitHub.
Find a bug, a typo, or something thatβs not documented well? Weβd love for you to open an issue telling me what I can improve!
Contributions are welcome, and they are greatly appreciated!
arturdev, [email protected]
Unrealm is available under the MIT license. See the LICENSE file for more info.
link |
Stars: 527 |
Last commit: 3 weeks ago |
Fixed build error related to RealmSwiftObject
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics