From a33219cb219cf91c47d6c637c1ef43894bcbb799 Mon Sep 17 00:00:00 2001 From: Konstantin Koval Date: Sun, 5 Jul 2015 20:32:22 +0200 Subject: [PATCH] cleanup --- Pod/Classes/Mirror.swift | 48 +++++------------------------------- Pod/Classes/TypeMirror.swift | 12 --------- 2 files changed, 6 insertions(+), 54 deletions(-) delete mode 100644 Pod/Classes/TypeMirror.swift diff --git a/Pod/Classes/Mirror.swift b/Pod/Classes/Mirror.swift index 61a3265..f2c4a86 100644 --- a/Pod/Classes/Mirror.swift +++ b/Pod/Classes/Mirror.swift @@ -10,9 +10,12 @@ import Foundation public struct Mirror { public typealias MirrorItem = (key: String, data: MirrorType) + private let mirror: MirrorType + private var instance: T public init (_ x: T) { + instance = x mirror = reflect(x) } @@ -31,9 +34,9 @@ public struct Mirror { //MARK: - public subscript (key: String) -> Any? { - let res = findFirst(self) { $0.key == key } - return res.map { $0.data.value } - } + let res = findFirst(self) { $0.key == key } + return res.map { $0.data.value } + } public func get(key: String) -> U? { let res = findFirst(self) { $0.key == key } @@ -60,44 +63,6 @@ public struct Mirror { return result } - - - - - // func value(instance: T, key: String) -> Any? { - // var result: Any? = nil - // - // iterate { childKey, childVal in - // if childKey == key { - // result = childVal.value - // } - // return - // } - // return result - // } - - - func setValue(instance: T, value: U) { - - // iterate { childKey, childMirror in - // if childKey == key { - // return childMirror.value - // } - // } - // return nil - } - - /* - - static func fromDictionary(instance: NSDictionary) -> T { - let result = T() - for (key, val) in instance { - // result <-- instance[key] - } - - return result - } - */ } extension Mirror : CollectionType, SequenceType { @@ -117,7 +82,6 @@ extension Mirror : CollectionType, SequenceType { public subscript (i: Int) -> MirrorItem { return mirror[i] } - } infix operator --> {} diff --git a/Pod/Classes/TypeMirror.swift b/Pod/Classes/TypeMirror.swift deleted file mode 100644 index 6ee03d7..0000000 --- a/Pod/Classes/TypeMirror.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// File.swift -// Mirror -// -// Created by Kostiantyn Koval on 05/07/15. -// -// - -import Foundation - -public struct TypeMirror { -}