diff --git a/HandySwift.xcodeproj/project.pbxproj b/HandySwift.xcodeproj/project.pbxproj index e327c15..aea9705 100644 --- a/HandySwift.xcodeproj/project.pbxproj +++ b/HandySwift.xcodeproj/project.pbxproj @@ -9,7 +9,8 @@ /* Begin PBXBuildFile section */ 823B2B351C24AAB7007B3CDD /* HandySwift.h in Headers */ = {isa = PBXBuildFile; fileRef = 823B2B341C24AAB7007B3CDD /* HandySwift.h */; settings = {ATTRIBUTES = (Public, ); }; }; 823B2B3C1C24AAB7007B3CDD /* HandySwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 823B2B311C24AAB6007B3CDD /* HandySwift.framework */; }; - 823B2B411C24AAB7007B3CDD /* HandySwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */; }; + 823B2B4D1C24ABA4007B3CDD /* IntegerTypeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */; }; + 823B2B501C24AC00007B3CDD /* IntegerTypeExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -27,8 +28,9 @@ 823B2B341C24AAB7007B3CDD /* HandySwift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HandySwift.h; sourceTree = ""; }; 823B2B361C24AAB7007B3CDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 823B2B3B1C24AAB7007B3CDD /* HandySwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HandySwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandySwiftTests.swift; sourceTree = ""; }; 823B2B421C24AAB7007B3CDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IntegerTypeExtension.swift; path = Extensions/IntegerTypeExtension.swift; sourceTree = ""; }; + 823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IntegerTypeExtensionTests.swift; path = Extensions/IntegerTypeExtensionTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -71,6 +73,7 @@ 823B2B331C24AAB7007B3CDD /* HandySwift */ = { isa = PBXGroup; children = ( + 823B2B4B1C24AB7F007B3CDD /* Extensions */, 823B2B341C24AAB7007B3CDD /* HandySwift.h */, 823B2B361C24AAB7007B3CDD /* Info.plist */, ); @@ -80,12 +83,28 @@ 823B2B3F1C24AAB7007B3CDD /* HandySwiftTests */ = { isa = PBXGroup; children = ( - 823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */, + 823B2B4E1C24ABD8007B3CDD /* Extensions */, 823B2B421C24AAB7007B3CDD /* Info.plist */, ); path = HandySwiftTests; sourceTree = ""; }; + 823B2B4B1C24AB7F007B3CDD /* Extensions */ = { + isa = PBXGroup; + children = ( + 823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */, + ); + name = Extensions; + sourceTree = ""; + }; + 823B2B4E1C24ABD8007B3CDD /* Extensions */ = { + isa = PBXGroup; + children = ( + 823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */, + ); + name = Extensions; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -194,6 +213,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 823B2B4D1C24ABA4007B3CDD /* IntegerTypeExtension.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -201,7 +221,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 823B2B411C24AAB7007B3CDD /* HandySwiftTests.swift in Sources */, + 823B2B501C24AC00007B3CDD /* IntegerTypeExtensionTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -308,6 +328,7 @@ 823B2B461C24AAB7007B3CDD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -318,12 +339,14 @@ PRODUCT_BUNDLE_IDENTIFIER = com.flinesoft.HandySwift; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; 823B2B471C24AAB7007B3CDD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -376,6 +399,7 @@ 823B2B471C24AAB7007B3CDD /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 823B2B481C24AAB7007B3CDD /* Build configuration list for PBXNativeTarget "HandySwiftTests" */ = { isa = XCConfigurationList; @@ -384,6 +408,7 @@ 823B2B4A1C24AAB7007B3CDD /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/HandySwift.xcworkspace/contents.xcworkspacedata b/HandySwift.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..a21f78b --- /dev/null +++ b/HandySwift.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/HandySwift/Extensions/IntegerTypeExtension.swift b/HandySwift/Extensions/IntegerTypeExtension.swift new file mode 100644 index 0000000..8210c12 --- /dev/null +++ b/HandySwift/Extensions/IntegerTypeExtension.swift @@ -0,0 +1,29 @@ +// +// IntegerTypeExtension.swift +// HandySwift +// +// Created by Cihat Gündüz on 18.12.15. +// Copyright © 2015 Flinesoft. All rights reserved. +// + +import Foundation + +public extension IntegerType { + + public func times(closure: () -> ()) { + guard self > 0 else { return } + + for _ in 1...self { + closure() + } + } + + public func times(closure: (Self) -> ()) { + guard self > 0 else { return } + + for i in 1...self { + closure(i) + } + } + +} diff --git a/HandySwift/Info.plist b/HandySwift/Info.plist index d3de8ee..11d7458 100644 --- a/HandySwift/Info.plist +++ b/HandySwift/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 0.1 CFBundleSignature ???? CFBundleVersion diff --git a/HandySwiftTests/Extensions/IntegerTypeExtensionTests.swift b/HandySwiftTests/Extensions/IntegerTypeExtensionTests.swift new file mode 100644 index 0000000..8caaf6a --- /dev/null +++ b/HandySwiftTests/Extensions/IntegerTypeExtensionTests.swift @@ -0,0 +1,48 @@ +// +// IntegerTypeExtensionTests.swift +// HandySwift +// +// Created by Cihat Gündüz on 18.12.15. +// Copyright © 2015 Flinesoft. All rights reserved. +// + +import XCTest + +@testable import HandySwift + +class IntegerTypeExtensionTests: XCTestCase { + + func testTimesClosureWithoutArgument() { + var testString = "" + + 0.times { + testString += "." + } + + XCTAssertEqual(testString, "") + + 3.times { + testString += "." + } + + XCTAssertEqual(testString, "...") + } + + func testTimesClosureWithArgument() { + var testString = "" + + 0.times { i in + testString += "\(i)" + } + + XCTAssertEqual(testString, "") + + 3.times { i in + testString += "\(i)" + } + + XCTAssertEqual(testString, "123") + } + + +} diff --git a/HandySwiftTests/HandySwiftTests.swift b/HandySwiftTests/HandySwiftTests.swift deleted file mode 100644 index 8e7993f..0000000 --- a/HandySwiftTests/HandySwiftTests.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// HandySwiftTests.swift -// HandySwiftTests -// -// Created by Cihat Gündüz on 18.12.15. -// Copyright © 2015 Flinesoft. All rights reserved. -// - -import XCTest -@testable import HandySwift - -class HandySwiftTests: XCTestCase { - - override func setUp() { - super.setUp() - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measureBlock { - // Put the code you want to measure the time of here. - } - } - -} diff --git a/UsageExamples.playground/Contents.swift b/UsageExamples.playground/Contents.swift new file mode 100644 index 0000000..489f1cd --- /dev/null +++ b/UsageExamples.playground/Contents.swift @@ -0,0 +1,2 @@ +import HandySwift + diff --git a/UsageExamples.playground/contents.xcplayground b/UsageExamples.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/UsageExamples.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/UsageExamples.playground/playground.xcworkspace/contents.xcworkspacedata b/UsageExamples.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/UsageExamples.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/UsageExamples.playground/timeline.xctimeline b/UsageExamples.playground/timeline.xctimeline new file mode 100644 index 0000000..bf468af --- /dev/null +++ b/UsageExamples.playground/timeline.xctimeline @@ -0,0 +1,6 @@ + + + + +