iMark21 / MMRealmWrapper

An easy way to manage your Realm Database with Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MMRealmWrapper

An easy way to manage your Realm Database with Swift

This library uses library from RealmManager by markcdb - trying to make it easier to manage your own databases with REALM.

Requirements

  • iOS 9
  • ARC

Installation

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

pod 'MMRealmWrapper'

How it works

Initialize DB

    • Parameter version: version number of your DB. Increment your version number when you have to update your db file.
    public func configureDB(version: UInt64) 

Initialize SHARED DB

    • ApplicationGroupIdentifier: Application Security Group Identifier defined on iTunesConnect account like app.identifier.com. Version:number of your DB. Increment your version number when you have to update your db file.
    public configureSharedDB(ApplicationGroupIdentifier:String, version: UInt64)

Save or Update Objects

    • Save Realm Object
    public func save(T: Object) 
    • Save Realm Object with completion: returns success or not for this task.
    public func saveWithCompletion(T: Object?, completion: @escaping (_ success : Bool) -> Void)
    • Save an Array of Realm Objects with completion: returns success or not for this task.
    public func saveArrayObjects(T: [Object], completion: @escaping (_ success : Bool) -> Void) 

Get Objects

    • Get array of objects by class
    public func getAllListOf(T: Object, completionHandler: @escaping(_ result:[Object]) -> Void) 
    • Get unique object by Identifier
    public func getFetchObject(T: Object, objectID: String, completionHandler: @escaping(_ result:Object?) -> Void)
    • Get unique object by custom primary key for Realm Object
    public func getFetchObjectWithCustomPrimareyKey(T: Object, objectPrimaryKey: String, objectPrimaryKeyValue: String, completionHandler: @escaping(_ result:Object?) -> Void)
    • Get list of objects by condition
    public func getFetchList(T: Object, condition: String?, completionHandler: @escaping(_ result:[Object]) -> Void)

Delete Objects

    • Delete object providing Identifier
    public func deleteObjectById(T: Object, objectID: String, completionHandler: @escaping(_ success:Bool) -> Void)
    • Delete object providing your own customPrimareyKey
    public func deleteObjectByCustomPrimaryKey(T: Object, objectPrimaryKey: String, objectPrimaryKeyValue: String, completionHandler: @escaping(_ success:Bool) -> Void)
    • Delete object / objects by condition
    public func deleteObjectByCondition(T: Object, condition: String, completionHandler: @escaping(_ success:Bool) -> Void)
    • Delete all objects of class
    public func deleteAllObjectWithCompletion(T: Object, completionHandler: @escaping(_ success:Bool) -> Void)
    • Delete object providing a object
    public func deleteObjectWithCompletion(T: Object, completionHandler: @escaping(_ success:Bool) -> Void)
    • Delete all database
    public func deleteAllDataBase()

Author

iMark21, marques.jm@icloud.com

License

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

About

An easy way to manage your Realm Database with Swift

License:MIT License


Languages

Language:Swift 93.3%Language:Ruby 6.7%