From 8a3d823b7716503fc0bc73a04b2649a64acb1835 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 25 May 2016 23:44:56 +0300 Subject: [PATCH] refactoring --- LeadKit/LeadKit.xcodeproj/project.pbxproj | 8 ++++---- .../NSIndexPath/NSIndexPath+ImmutableIndexPath.swift | 11 +++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/LeadKit/LeadKit.xcodeproj/project.pbxproj b/LeadKit/LeadKit.xcodeproj/project.pbxproj index 28200325..6112b3f2 100644 --- a/LeadKit/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit/LeadKit.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 787682FA1CAD40C300532AB3 /* StaticEstimatedViewHeightProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787682F91CAD40C200532AB3 /* StaticEstimatedViewHeightProtocol.swift */; }; 787783631CA03CA0001CDC9B /* NSIndexPath+ImmutableIndexPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787783621CA03CA0001CDC9B /* NSIndexPath+ImmutableIndexPath.swift */; }; 787783671CA04D4A001CDC9B /* NSString+SizeCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787783661CA04D4A001CDC9B /* NSString+SizeCalculation.swift */; }; + 788EC15A1CF64528009CFB6B /* UIStoryboard+InstantiateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 788EC1591CF64528009CFB6B /* UIStoryboard+InstantiateViewController.swift */; }; 78A74EA91C6B373700FE9724 /* UIView+DefaultNibName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78A74EA81C6B373700FE9724 /* UIView+DefaultNibName.swift */; }; 78B0FC7D1C6B2BE200358B64 /* LogFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78B0FC7C1C6B2BE200358B64 /* LogFormatter.swift */; }; 78B0FC7F1C6B2C4D00358B64 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78B0FC7E1C6B2C4D00358B64 /* Log.swift */; }; @@ -20,7 +21,6 @@ 78CFEE2E1C5C456B00F50370 /* LeadKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 78CFEE2D1C5C456B00F50370 /* LeadKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 78CFEE351C5C456B00F50370 /* LeadKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78CFEE2A1C5C456B00F50370 /* LeadKit.framework */; }; 78CFEE3A1C5C456B00F50370 /* LeadKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78CFEE391C5C456B00F50370 /* LeadKitTests.swift */; }; - 78CFEE511C5C45E500F50370 /* UIStoryboard in Sources */ = {isa = PBXBuildFile; fileRef = 78CFEE451C5C45E500F50370 /* UIStoryboard */; }; 78CFEE521C5C45E500F50370 /* UITableView+CellRegistration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78CFEE461C5C45E500F50370 /* UITableView+CellRegistration.swift */; }; 78CFEE531C5C45E500F50370 /* UITableView+DequeueCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78CFEE471C5C45E500F50370 /* UITableView+DequeueCustomCell.swift */; }; 78CFEE541C5C45E500F50370 /* UIView+LoadFromNib.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78CFEE481C5C45E500F50370 /* UIView+LoadFromNib.swift */; }; @@ -52,6 +52,7 @@ 787682F91CAD40C200532AB3 /* StaticEstimatedViewHeightProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaticEstimatedViewHeightProtocol.swift; sourceTree = ""; }; 787783621CA03CA0001CDC9B /* NSIndexPath+ImmutableIndexPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSIndexPath+ImmutableIndexPath.swift"; sourceTree = ""; }; 787783661CA04D4A001CDC9B /* NSString+SizeCalculation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSString+SizeCalculation.swift"; sourceTree = ""; }; + 788EC1591CF64528009CFB6B /* UIStoryboard+InstantiateViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStoryboard+InstantiateViewController.swift"; sourceTree = ""; }; 78A74EA81C6B373700FE9724 /* UIView+DefaultNibName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIView+DefaultNibName.swift"; path = "LeadKit/Extensions/UIView/UIView+DefaultNibName.swift"; sourceTree = SOURCE_ROOT; }; 78B0FC7C1C6B2BE200358B64 /* LogFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogFormatter.swift; sourceTree = ""; }; 78B0FC7E1C6B2C4D00358B64 /* Log.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = ""; }; @@ -62,7 +63,6 @@ 78CFEE341C5C456B00F50370 /* LeadKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LeadKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 78CFEE391C5C456B00F50370 /* LeadKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeadKitTests.swift; sourceTree = ""; }; 78CFEE3B1C5C456B00F50370 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 78CFEE451C5C45E500F50370 /* UIStoryboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = folder; name = UIStoryboard; path = LeadKit/Extensions/UIStoryboard; sourceTree = SOURCE_ROOT; }; 78CFEE461C5C45E500F50370 /* UITableView+CellRegistration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UITableView+CellRegistration.swift"; path = "LeadKit/Extensions/UITableView/UITableView+CellRegistration.swift"; sourceTree = SOURCE_ROOT; }; 78CFEE471C5C45E500F50370 /* UITableView+DequeueCustomCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UITableView+DequeueCustomCell.swift"; path = "LeadKit/Extensions/UITableView/UITableView+DequeueCustomCell.swift"; sourceTree = SOURCE_ROOT; }; 78CFEE481C5C45E500F50370 /* UIView+LoadFromNib.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIView+LoadFromNib.swift"; path = "LeadKit/Extensions/UIView/UIView+LoadFromNib.swift"; sourceTree = SOURCE_ROOT; }; @@ -247,7 +247,7 @@ C372153938A7B7D327F55124 /* UIStoryboard */ = { isa = PBXGroup; children = ( - 78CFEE451C5C45E500F50370 /* UIStoryboard */, + 788EC1591CF64528009CFB6B /* UIStoryboard+InstantiateViewController.swift */, ); path = UIStoryboard; sourceTree = ""; @@ -414,12 +414,12 @@ 78CFEE521C5C45E500F50370 /* UITableView+CellRegistration.swift in Sources */, 78B0FC7F1C6B2C4D00358B64 /* Log.swift in Sources */, 78CFEE571C5C45E500F50370 /* StaticNibNameProtocol.swift in Sources */, + 788EC15A1CF64528009CFB6B /* UIStoryboard+InstantiateViewController.swift in Sources */, 787783671CA04D4A001CDC9B /* NSString+SizeCalculation.swift in Sources */, 78CFEE531C5C45E500F50370 /* UITableView+DequeueCustomCell.swift in Sources */, 78E59B1B1C77470A00C6BFE9 /* ViewsGenerator.swift in Sources */, 78B0FC811C6B2CD500358B64 /* App.swift in Sources */, 78CFEE551C5C45E500F50370 /* NibNameProtocol.swift in Sources */, - 78CFEE511C5C45E500F50370 /* UIStoryboard in Sources */, 78CFEE561C5C45E500F50370 /* ReuseIdentifierProtocol.swift in Sources */, 78E59B191C773EE600C6BFE9 /* ObjectsGenerator.swift in Sources */, 78CFEE5B1C5C45E500F50370 /* ViewModelProtocol.swift in Sources */, diff --git a/LeadKit/LeadKit/Extensions/NSIndexPath/NSIndexPath+ImmutableIndexPath.swift b/LeadKit/LeadKit/Extensions/NSIndexPath/NSIndexPath+ImmutableIndexPath.swift index 6df07654..a1d34a31 100644 --- a/LeadKit/LeadKit/Extensions/NSIndexPath/NSIndexPath+ImmutableIndexPath.swift +++ b/LeadKit/LeadKit/Extensions/NSIndexPath/NSIndexPath+ImmutableIndexPath.swift @@ -11,18 +11,13 @@ import Foundation // http://stackoverflow.com/a/21686163 extension NSIndexPath { - /** - method which check instance class and create immutable copy if class is not NSIndexPath - - - returns: immutable NSIndexPath instance - */ - - func immutableIndexPath() -> NSIndexPath { + /// return immutable copy if class is not NSIndexPath or return self + var immutableIndexPath: NSIndexPath { if Mirror(reflecting: self).subjectType == NSIndexPath.self { // check for UIMutableIndexPath return self } - return NSIndexPath(forItem: self.item, inSection: self.section) + return NSIndexPath(forItem: item, inSection: section) } }