RealmWrapper
RealmWrapper is wrapper library for RealmSwift in realm-cocoa
If you use RealmWrapper, you can easily use UI update through Notification and Transaction processing.
Also, you do not have to worry about the retain cycle when using self in the Notification block.
At a Glance
If you use RealmSwift, you have to be careful about try statement and thread processing every transaction.
However, In RealmManageable which manages one realm file, transaction processing is performed using Realm-only DispatchQueue.
RealmProxiable, which owns RealmManageable, can easily add, modify or delete models without having to worry about try statement and thread processing.
User Model
Using RealmSwift
Using RealmWrapper
Threading
- By default, you can use the transaction function to process a Realm Transaction in MainThread
- It can be implemented by a background thread using DispatchQueue and isSync parameters.
- You can add completion closure.
Getting Started
- Create a
RealmManager
that manages one realm file.
- Create a
RealmProxy
that is responsible for the CRUD function to be accessed by the Controller.
- If you want to register the notification of the status of the Realm object in the controller, you can register the notification in RealmQuery.
Also, since RealmQuery is doing weak handling to prevent the retain cycle, you can use closures without worrying about the retain cycle if you pass only self.
Usage
RealmManageable Property
Property | Type | Default | Description |
---|---|---|---|
isUseInMemory |
Bool |
required |
Use InMemory Realm |
fileName |
Bool |
required |
Realm File Name |
appGroupIdentifier |
String? |
nil |
Value for Realm file directory for App Extension |
Example
- run carthage update
- open RealmWrapper.xcodeproj
- run RealmWrapperExample
Installation
CocoaPods (iOS 9+)
Carthage (iOS 9+)
Swift Package Manager (Swift 5.2+, iOS 11+)
LICENSE
These works are available under the MIT license. See the [LICENSE]file
for more info.