Latest 0.9.1
Homepage https://github.com/muzcity/MZVariant
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Example

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

Requirements

Installation

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

pod "MZVariant"

Usage

// used for basic type
var variant = MZVariant("1234")
let variant1 = MZVariant(98765)

if let value = variant.value(type: String.self) {
    print("(value)")
}

if let value = variant1.value(type: Int.self) {
    print("(value)")
}

print("(variant.setValue(value: "5555"))")

// type check function.
if variant.isIncludedType(value: Int.self) {
    print("inner type is Int")
}
else {
    print("inner type is other")
}

if variant.isIncludedType(value: String.self) {
    print("inner type is String")
}
else {
    print("inner type is other")
}

// used for class
let c = SomeClass()
let variant2 = MZVariant(c)

if let value = variant2.value(type: SomeClass.self) {
    print("(value.num)")
}

// used for dictionary
var dictionary : [String:MZVariant] = [:]

dictionary["key"] = MZVariant("mzvariant value")
dictionary["key1"] = MZVariant(123.4567)

if let value = dictionary["key"]?.value(type: String.self) {
    print("(value)")
}

if let value = dictionary["key1"]?.value(type: Double.self) {
    print("(value)")
}

Author

[email protected]

License

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

Latest podspec

{
    "name": "MZVariant",
    "version": "0.9.1",
    "summary": "Use MZVariant type instead of Any and AnyObject.",
    "description": "A structure created to support Variant types.nIf it conforms to the MZVariantable protocol, it can also be used with custom classes and structures.",
    "homepage": "https://github.com/muzcity/MZVariant",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "muzcity": "[email protected]"
    },
    "source": {
        "git": "https://github.com/muzcity/MZVariant.git",
        "tag": "0.9.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MZVariant/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This