Skip to content

Commit ab88bd6

Browse files
committed
Merge branch 'release/0.1'
# Conflicts: # README.md
2 parents 0950759 + a7d60fc commit ab88bd6

File tree

12 files changed

+249
-42
lines changed

12 files changed

+249
-42
lines changed

.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
## Build generated
6+
build/
7+
DerivedData
8+
9+
## Various settings
10+
*.pbxuser
11+
!default.pbxuser
12+
*.mode1v3
13+
!default.mode1v3
14+
*.mode2v3
15+
!default.mode2v3
16+
*.perspectivev3
17+
!default.perspectivev3
18+
xcuserdata
19+
20+
## Other
21+
*.xccheckout
22+
*.moved-aside
23+
*.xcuserstate
24+
*.xcscmblueprint
25+
26+
## Obj-C/Swift specific
27+
*.hmap
28+
*.ipa
29+
30+
# Swift Package Manager
31+
#
32+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
33+
# Packages/
34+
.build/
35+
36+
# CocoaPods
37+
#
38+
# We recommend against adding the Pods directory to your .gitignore. However
39+
# you should judge for yourself, the pros and cons are mentioned at:
40+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
41+
#
42+
# Pods/
43+
44+
# Carthage
45+
#
46+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
47+
# Carthage/Checkouts
48+
49+
Carthage/Build
50+
51+
# fastlane
52+
#
53+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
54+
# screenshots whenever they are needed.
55+
# For more information about the recommended setup visit:
56+
# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md
57+
58+
fastlane/report.xml
59+
fastlane/screenshots

HandySwift.xcodeproj/project.pbxproj

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
/* Begin PBXBuildFile section */
1010
823B2B351C24AAB7007B3CDD /* HandySwift.h in Headers */ = {isa = PBXBuildFile; fileRef = 823B2B341C24AAB7007B3CDD /* HandySwift.h */; settings = {ATTRIBUTES = (Public, ); }; };
1111
823B2B3C1C24AAB7007B3CDD /* HandySwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 823B2B311C24AAB6007B3CDD /* HandySwift.framework */; };
12-
823B2B411C24AAB7007B3CDD /* HandySwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */; };
12+
823B2B4D1C24ABA4007B3CDD /* IntegerTypeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */; };
13+
823B2B501C24AC00007B3CDD /* IntegerTypeExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */; };
1314
/* End PBXBuildFile section */
1415

1516
/* Begin PBXContainerItemProxy section */
@@ -27,8 +28,9 @@
2728
823B2B341C24AAB7007B3CDD /* HandySwift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HandySwift.h; sourceTree = "<group>"; };
2829
823B2B361C24AAB7007B3CDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2930
823B2B3B1C24AAB7007B3CDD /* HandySwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HandySwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
30-
823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandySwiftTests.swift; sourceTree = "<group>"; };
3131
823B2B421C24AAB7007B3CDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
32+
823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IntegerTypeExtension.swift; path = Extensions/IntegerTypeExtension.swift; sourceTree = "<group>"; };
33+
823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IntegerTypeExtensionTests.swift; path = Extensions/IntegerTypeExtensionTests.swift; sourceTree = "<group>"; };
3234
/* End PBXFileReference section */
3335

3436
/* Begin PBXFrameworksBuildPhase section */
@@ -71,6 +73,7 @@
7173
823B2B331C24AAB7007B3CDD /* HandySwift */ = {
7274
isa = PBXGroup;
7375
children = (
76+
823B2B4B1C24AB7F007B3CDD /* Extensions */,
7477
823B2B341C24AAB7007B3CDD /* HandySwift.h */,
7578
823B2B361C24AAB7007B3CDD /* Info.plist */,
7679
);
@@ -80,12 +83,28 @@
8083
823B2B3F1C24AAB7007B3CDD /* HandySwiftTests */ = {
8184
isa = PBXGroup;
8285
children = (
83-
823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */,
86+
823B2B4E1C24ABD8007B3CDD /* Extensions */,
8487
823B2B421C24AAB7007B3CDD /* Info.plist */,
8588
);
8689
path = HandySwiftTests;
8790
sourceTree = "<group>";
8891
};
92+
823B2B4B1C24AB7F007B3CDD /* Extensions */ = {
93+
isa = PBXGroup;
94+
children = (
95+
823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */,
96+
);
97+
name = Extensions;
98+
sourceTree = "<group>";
99+
};
100+
823B2B4E1C24ABD8007B3CDD /* Extensions */ = {
101+
isa = PBXGroup;
102+
children = (
103+
823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */,
104+
);
105+
name = Extensions;
106+
sourceTree = "<group>";
107+
};
89108
/* End PBXGroup section */
90109

91110
/* Begin PBXHeadersBuildPhase section */
@@ -194,14 +213,15 @@
194213
isa = PBXSourcesBuildPhase;
195214
buildActionMask = 2147483647;
196215
files = (
216+
823B2B4D1C24ABA4007B3CDD /* IntegerTypeExtension.swift in Sources */,
197217
);
198218
runOnlyForDeploymentPostprocessing = 0;
199219
};
200220
823B2B371C24AAB7007B3CDD /* Sources */ = {
201221
isa = PBXSourcesBuildPhase;
202222
buildActionMask = 2147483647;
203223
files = (
204-
823B2B411C24AAB7007B3CDD /* HandySwiftTests.swift in Sources */,
224+
823B2B501C24AC00007B3CDD /* IntegerTypeExtensionTests.swift in Sources */,
205225
);
206226
runOnlyForDeploymentPostprocessing = 0;
207227
};
@@ -308,6 +328,7 @@
308328
823B2B461C24AAB7007B3CDD /* Debug */ = {
309329
isa = XCBuildConfiguration;
310330
buildSettings = {
331+
CLANG_ENABLE_MODULES = YES;
311332
DEFINES_MODULE = YES;
312333
DYLIB_COMPATIBILITY_VERSION = 1;
313334
DYLIB_CURRENT_VERSION = 1;
@@ -318,12 +339,14 @@
318339
PRODUCT_BUNDLE_IDENTIFIER = com.flinesoft.HandySwift;
319340
PRODUCT_NAME = "$(TARGET_NAME)";
320341
SKIP_INSTALL = YES;
342+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
321343
};
322344
name = Debug;
323345
};
324346
823B2B471C24AAB7007B3CDD /* Release */ = {
325347
isa = XCBuildConfiguration;
326348
buildSettings = {
349+
CLANG_ENABLE_MODULES = YES;
327350
DEFINES_MODULE = YES;
328351
DYLIB_COMPATIBILITY_VERSION = 1;
329352
DYLIB_CURRENT_VERSION = 1;
@@ -376,6 +399,7 @@
376399
823B2B471C24AAB7007B3CDD /* Release */,
377400
);
378401
defaultConfigurationIsVisible = 0;
402+
defaultConfigurationName = Release;
379403
};
380404
823B2B481C24AAB7007B3CDD /* Build configuration list for PBXNativeTarget "HandySwiftTests" */ = {
381405
isa = XCConfigurationList;
@@ -384,6 +408,7 @@
384408
823B2B4A1C24AAB7007B3CDD /* Release */,
385409
);
386410
defaultConfigurationIsVisible = 0;
411+
defaultConfigurationName = Release;
387412
};
388413
/* End XCConfigurationList section */
389414
};

HandySwift.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// IntegerTypeExtension.swift
3+
// HandySwift
4+
//
5+
// Created by Cihat Gündüz on 18.12.15.
6+
// Copyright © 2015 Flinesoft. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public extension IntegerType {
12+
13+
public func times(closure: () -> ()) {
14+
guard self > 0 else { return }
15+
16+
for _ in 1...self {
17+
closure()
18+
}
19+
}
20+
21+
public func times(closure: (Self) -> ()) {
22+
guard self > 0 else { return }
23+
24+
for i in 1...self {
25+
closure(i)
26+
}
27+
}
28+
29+
}

HandySwift/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>0.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// IntegerTypeExtensionTests.swift
3+
// HandySwift
4+
//
5+
// Created by Cihat Gündüz on 18.12.15.
6+
// Copyright © 2015 Flinesoft. All rights reserved.
7+
//
8+
9+
import XCTest
10+
11+
@testable import HandySwift
12+
13+
class IntegerTypeExtensionTests: XCTestCase {
14+
15+
func testTimesClosureWithoutArgument() {
16+
var testString = ""
17+
18+
0.times {
19+
testString += "."
20+
}
21+
22+
XCTAssertEqual(testString, "")
23+
24+
3.times {
25+
testString += "."
26+
}
27+
28+
XCTAssertEqual(testString, "...")
29+
}
30+
31+
func testTimesClosureWithArgument() {
32+
var testString = ""
33+
34+
0.times { i in
35+
testString += "\(i)"
36+
}
37+
38+
XCTAssertEqual(testString, "")
39+
40+
3.times { i in
41+
testString += "\(i)"
42+
}
43+
44+
XCTAssertEqual(testString, "123")
45+
}
46+
47+
48+
}

HandySwiftTests/HandySwiftTests.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
11
# HandySwift
2-
Handy Swift features that didn't make it to the Swift standard library.
2+
3+
The goal of this library is to provide handy features that didn't make it to the Swift standard library (yet) due to many different reasons. Those could be that the Swift community wants to keep the standard library clean and manageable or simply hasn't finished discussion on a specific feature yet.
4+
5+
## Installation
6+
7+
TODO: Installation instructions are missing. Carthage, Cocoapods and Swift Package Manager support are planned.
8+
9+
## Usage
10+
11+
Please have a look at the UsageExamples.playground for a complete list of features provided.
12+
13+
### IntegerTypeExtension
14+
15+
#### .times
16+
17+
```
18+
3.times{ array.append("Hello World!") }
19+
// => ["Hello World!", "Hello World!", "Hello World!"]
20+
```
21+
22+
```
23+
3.times{ array.append("Hello World #\($0)!") }
24+
// => ["Hello World #1!", "Hello World #2!", "Hello World #3!"]
25+
```
26+
27+
## Contributing
28+
29+
Contributions are welcome. Please just open an Issue on GitHub to discuss a point or request a feature or send a Pull Request with your suggestion. If there's a related discussion on the Swift Evolution mailing list, please also post the thread name with a link.
30+
31+
Pull requests with new features will only be accepted when the following are given:
32+
- The feature is **handy** but not (yet) part of the Swift standard library.
33+
- **Tests** for the new feature exist and all tests pass successfully.
34+
- **Usage examples** of the new feature are given in the Playgrounds.
35+
36+
## License
37+
This library is released under the [MIT License](http://opensource.org/licenses/MIT). See LICENSE for details.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import HandySwift
2+
3+
// MARK: - IntegerTypeExtension
4+
5+
// .times method
6+
7+
//
8+
// `n.times{ someCode }` – Calls someCode n times.
9+
//
10+
var array: [String] = []
11+
12+
3.times{ array.append("Hello World!") }
13+
array
14+
15+
array = []
16+
3.times{ array.append("Hello World #\($0)!") }
17+
array
18+
19+
20+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='ios'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

0 commit comments

Comments
 (0)