Latest 1.0.0
Homepage https://github.com/matsuokah/ExtensionProperty
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0, requires ARC
Authors

Extension Property

The utility interface for Associated Object.
If you use this, you can attach any variables in extension.

How To Use

protocol Animal {}

enum AnimalPropertyKeys: String, ExtensionPropertyKey {
    case name
}

final class Dog: Animal {}

extension Dog: ExtensionProperty {}

// Setter and Getter
extension Animal where Self: ExtensionProperty {
    var name: String {
        get {
            return getProperty(key: AnimalPropertyKeys.name, defaultValue: "")
        }

        set {
            setProperty(key: AnimalPropertyKeys.name, newValue: newValue)
        }
    }
}

let dog = Dog()
dog.name = "Autumn"

LICENSE

MIT, see also LICENSE

Latest podspec

{
    "name": "ExtensionProperty",
    "version": "1.0.0",
    "summary": "Attach property via Extension",
    "homepage": "https://github.com/matsuokah/ExtensionProperty",
    "license": "MIT",
    "authors": {
        "Hideki Matsuoka": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/matsuokah/ExtensionProperty.git",
        "tag": "1.0.0"
    },
    "source_files": "Source/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This