Giter VIP home page Giter VIP logo

swiftmirror's Introduction

SwiftMirror

Usage

  1. Struct and Enum
struct StructType {
    var a_1: String?
    var a_2: Int?
    var a_3: String?
}

// original Mirror
let mirror = Mirror(reflecting: StructType.init())
mirror.children.forEach({ print($0.label!) }    // print a_1, a_2, a_3


// Now, SwiftMirror:
let structMirror = SwiftMirror(type: StructType.self)
structMirror.children.forEach({ print($0!) })   // print a_1, a_2, a_3
enum EnumType {
    case aa_1
    case aa_2
    case aa_3
}

let enumMirror = SwiftMirror(type: EnumType.self)
enumMirror.children.forEach({ print($0!) })   // print aa_1, aa_2, aa_3
  1. Class
class SuperClassType: NSObject {
    var b_1: NSObject?
}

class ClassType: SuperClassType {
    var c_1: String?
    var c_2: Int?
    var c_3: String?
}

let classMirror = SwiftMirror(type: ClassType.self)
classMirror.children.forEach({ print($0!) })  // print c_1, c_2, c_3
classMirror.superClassMirror?.children.forEach({ print($0!) })  // print b_1

swiftmirror's People

Contributors

tannerjin avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.