Latest 1.2.3
License MIT
Platforms ios 10.0, requires ARC
Dependencies Realm, RealmSwift, SwiftyBeaver

Framework for iOS in Swift


This framework provides a DAO extra layer to use Realm in iOS development with Swift.
The main objective is to have basic transactions available for every Realm Object created in your project, without the need to re-write the code every time.

Object creation

First, we need to understand the Transferrable protocol:

public protocol Transferrable {
    associatedtype S

    func transfer() -> S    

This protocol gives us the possibility to create a Data Transfer Object for our entity:

class Animal: Object, Transferrable {
    typealias S = AnimalTransfer

    func transfer() -> S {
        return AnimalTransfer()

But if we feel like we don’t need this extra transfer object, we can also make the function return itself:

class Animal: Object, Transferrable {
    typealias S = Animal

    func transfer() -> S {
        return self

It is important to understand that this transfer object is the one that will be returned from the genericDAO, not the Realm Object!


Once we have created our objects, all we need to do is call the genericDao implementation:

let animalDAO = GenericDAO<Animal>()

and at this point we can call the functions we need:

let animals: [AnimalTransfer] = animalDAO.findAll()
let animal: AnimalTransfer = animalDAO.findByPrimaryKey(pk)

Latest podspec

    "name": "RealmDAO",
    "version": "1.2.3",
    "summary": "Swift framework to work with generic DAO's in Realm",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Igor Andruskiewitsch": "[email protected]"
    "platforms": {
        "ios": "10.0"
    "swift_version": "4.2",
    "requires_arc": true,
    "source": {
        "git": "",
        "tag": "v1.2.3",
        "submodules": true
    "source_files": "RealmDAO/**/*.{h,swift}",
    "dependencies": {
        "Realm": [],
        "RealmSwift": [],
        "SwiftyBeaver": []

Pin It on Pinterest

Share This