matghazaryan / Unrealm

Unrealm is an extension on RealmCocoa, which enables Swift native types to be saved in Realm.
MIT License
539 stars 73 forks source link
database db enum ios realm realmswift struct swift xcode

Unrealm Header Logo



Swift 5.1 Build Status Version Platform License Platform Platform


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 matghazaryan



Features

Unrealm supports the following types:

Example Project

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

Usage

All you have to do is

  1. Conform your Classes/Structs to Realmable protocol instead of inheriting from Object. Conform your Enums to RealmableEnum protocol.
  2. Register your Classes/Structs and Enums in AppDelegate's didFinishLaunchingWithOptions.
    Realm.registerRealmables(ToDoItem.self)

    That's it! Now you can store your Struct or Class object into Realm as usually you do with Objc Classes.

Pros and Cons

Pros 🎉

Cons 🍟

Installation

CocoaPods

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

pod 'Unrealm'

Swift Package Manager

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/matghazaryan/Unrealm.git

You need to use "master" branch instead of SPM.

ToDos

Contribution

⭐️ 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!

Author

matghazaryan, matevos14@gmail.com

License

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