Latest 1.1.0
Homepage https://github.com/Matzo/MirrorObject
License MIT
Platforms ios 9.0, requires ARC
Authors

Mirroring dynamic properties automatically.

CI Status
Version
License
Platform

Usage

Update an dynamic property, then it will be reflected to other object which has same identifier.

let a = User("u1", followers: 0)
let b = User("u1", followers: 0)

print(a.followers) // -> 0
print(b.followers) // -> 0

a.followers += 1

print(a.followers) // -> 1
print(b.followers) // -> 1

User class is defined as following.

import MirrorObject

class User: NSObject, MirrorObject {
    var id: String
    dynamic var followers: Int

    init(id: String, followers: Int) {
        self.id        = id
        self.followers = followers

        super.init()
        self.startMirroring()
    }

    deinit {
        self.stopMirroring()
    }

    func identifier() -> String {
        return id
    }
}

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

Requirements

  • iOS 8 or later

Installation

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

pod "MirrorObject"

Author

Matzo, [email protected]

License

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

Latest podspec

{
    "name": "MirrorObject",
    "version": "1.1.0",
    "summary": "Mirroring dynamic properties automatically.",
    "description": "Copy dynamic properties of objects that have same identifier.",
    "homepage": "https://github.com/Matzo/MirrorObject",
    "license": "MIT",
    "authors": {
        "Matzo": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Matzo/MirrorObject.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "swift_version": "4.1",
    "source_files": "Pod/Classes/**/*"
}

Pin It on Pinterest

Share This