From 192e2cdd27c80e38f0109f02e9eb6555e0249bb4 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Wed, 26 Apr 2017 10:56:17 +0300 Subject: [PATCH 1/5] Fix. Remove duplication of type(of:) --- LeadKit/LeadKit/Classes/Views/XibView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LeadKit/LeadKit/Classes/Views/XibView.swift b/LeadKit/LeadKit/Classes/Views/XibView.swift index 05a1fa7e..ae487583 100644 --- a/LeadKit/LeadKit/Classes/Views/XibView.swift +++ b/LeadKit/LeadKit/Classes/Views/XibView.swift @@ -27,7 +27,7 @@ open class XibView: UIView { /// Nib name used to instantiate inner view open var innerViewNibName: String { - return className(of: type(of: self)) + return String(describing: type(of: self)) } public convenience init() { From 00b7d11b3737eeb5d0302471540c091c15223ee8 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Wed, 26 Apr 2017 11:14:20 +0300 Subject: [PATCH 2/5] Fix. Remove `Type` --- LeadKit/LeadKit/Classes/Views/XibView.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/LeadKit/LeadKit/Classes/Views/XibView.swift b/LeadKit/LeadKit/Classes/Views/XibView.swift index ae487583..b9049845 100644 --- a/LeadKit/LeadKit/Classes/Views/XibView.swift +++ b/LeadKit/LeadKit/Classes/Views/XibView.swift @@ -27,7 +27,12 @@ open class XibView: UIView { /// Nib name used to instantiate inner view open var innerViewNibName: String { - return String(describing: type(of: self)) + let clsName = String(describing: type(of: self)) + if let typeRange = clsName.range(of: ".Type") { + return clsName.substring(to: typeRange.lowerBound) + } else { + return clsName + } } public convenience init() { From 04a558b70f4b6247e2290ba9b9dcf4ff67c7b285 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Wed, 26 Apr 2017 11:46:38 +0300 Subject: [PATCH 3/5] Fix. Remove duplications --- LeadKit/LeadKit/Classes/Views/XibView.swift | 7 +------ .../UIViewController/UIViewController+XibName.swift | 2 +- LeadKit/LeadKit/Functions/Any+TypeName.swift | 4 ++++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/LeadKit/LeadKit/Classes/Views/XibView.swift b/LeadKit/LeadKit/Classes/Views/XibView.swift index b9049845..b94db6fe 100644 --- a/LeadKit/LeadKit/Classes/Views/XibView.swift +++ b/LeadKit/LeadKit/Classes/Views/XibView.swift @@ -27,12 +27,7 @@ open class XibView: UIView { /// Nib name used to instantiate inner view open var innerViewNibName: String { - let clsName = String(describing: type(of: self)) - if let typeRange = clsName.range(of: ".Type") { - return clsName.substring(to: typeRange.lowerBound) - } else { - return clsName - } + return className(of: self) } public convenience init() { diff --git a/LeadKit/LeadKit/Extensions/UIViewController/UIViewController+XibName.swift b/LeadKit/LeadKit/Extensions/UIViewController/UIViewController+XibName.swift index 91b65bac..4a41f581 100644 --- a/LeadKit/LeadKit/Extensions/UIViewController/UIViewController+XibName.swift +++ b/LeadKit/LeadKit/Extensions/UIViewController/UIViewController+XibName.swift @@ -30,7 +30,7 @@ extension UIViewController { - returns: type name string */ open class var xibName: String { - return className(of: self) + return typeName(of: self) } } diff --git a/LeadKit/LeadKit/Functions/Any+TypeName.swift b/LeadKit/LeadKit/Functions/Any+TypeName.swift index addad2a9..6de9cb91 100644 --- a/LeadKit/LeadKit/Functions/Any+TypeName.swift +++ b/LeadKit/LeadKit/Functions/Any+TypeName.swift @@ -35,3 +35,7 @@ public func className(of type: T) -> String { return clsName } } + +public func typeName(of type: T.Type) -> String { + return String(describing: type) +} From fa069c422a81f8a841c0995676fb2dbde4e57dd3 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Wed, 26 Apr 2017 16:05:24 +0300 Subject: [PATCH 4/5] Fix. Update version & add description --- LeadKit.podspec | 2 +- LeadKit/LeadKit/Functions/Any+TypeName.swift | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/LeadKit.podspec b/LeadKit.podspec index 98ea2c5f..9462fd5b 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.4.8" + s.version = "0.4.9" s.summary = "iOS framework with a bunch of tools for rapid development" s.homepage = "https://github.com/TouchInstinct/LeadKit" s.license = "Apache License, Version 2.0" diff --git a/LeadKit/LeadKit/Functions/Any+TypeName.swift b/LeadKit/LeadKit/Functions/Any+TypeName.swift index 6de9cb91..3654a72b 100644 --- a/LeadKit/LeadKit/Functions/Any+TypeName.swift +++ b/LeadKit/LeadKit/Functions/Any+TypeName.swift @@ -22,9 +22,9 @@ import Foundation -/// Function which returns string representation of type without ".Type" suffix +/// Function which returns string representation of object type without ".Type" suffix /// -/// - Parameter type: a type +/// - Parameter type: an object type /// - Returns: string representation of type without ".Type" suffix public func className(of type: T) -> String { let clsName = String(describing: type(of: type)) @@ -36,6 +36,10 @@ public func className(of type: T) -> String { } } +/// Function which returns string representation of class type without ".Type" suffix +/// +/// - Parameter type: an class type +/// - Returns: string representation of type without ".Type" suffix public func typeName(of type: T.Type) -> String { return String(describing: type) } From f1658f3380bbd04c0417a08a4f8f405d0e529338 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Wed, 26 Apr 2017 16:53:29 +0300 Subject: [PATCH 5/5] Fix. Comments --- LeadKit/LeadKit/Functions/Any+TypeName.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LeadKit/LeadKit/Functions/Any+TypeName.swift b/LeadKit/LeadKit/Functions/Any+TypeName.swift index 3654a72b..e117bd83 100644 --- a/LeadKit/LeadKit/Functions/Any+TypeName.swift +++ b/LeadKit/LeadKit/Functions/Any+TypeName.swift @@ -22,10 +22,10 @@ import Foundation -/// Function which returns string representation of object type without ".Type" suffix +/// Function which returns string representation of object type /// /// - Parameter type: an object type -/// - Returns: string representation of type without ".Type" suffix +/// - Returns: string representation of object type public func className(of type: T) -> String { let clsName = String(describing: type(of: type)) @@ -36,10 +36,10 @@ public func className(of type: T) -> String { } } -/// Function which returns string representation of class type without ".Type" suffix +/// Function which returns string representation of class type /// /// - Parameter type: an class type -/// - Returns: string representation of type without ".Type" suffix +/// - Returns: string representation of class type public func typeName(of type: T.Type) -> String { return String(describing: type) }