Skip to content

Commit 7c9cca8

Browse files
committed
Distribute Sources ["String", "Regex"]
1 parent c280f8e commit 7c9cca8

6 files changed

Lines changed: 120 additions & 32 deletions

File tree

AGString.xcodeproj/project.pbxproj

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
3D9C432E2274629C000A6585 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3D9C432C2274629C000A6585 /* LaunchScreen.storyboard */; };
2424
3D9C433422746323000A6585 /* AGString.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D9C429022745894000A6585 /* AGString.framework */; };
2525
3D9C433522746323000A6585 /* AGString.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3D9C429022745894000A6585 /* AGString.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
26+
BDB3A5A2236EF1B30041D167 /* AGRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDB3A5A1236EF1B30041D167 /* AGRegex.swift */; };
2627
/* End PBXBuildFile section */
2728

2829
/* Begin PBXContainerItemProxy section */
@@ -99,7 +100,7 @@
99100
3D9C432F2274629C000A6585 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
100101
3DB91AC4229AC263002668DA /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = SOURCE_ROOT; };
101102
3DF6F6282315616D00706C4E /* main.yml */ = {isa = PBXFileReference; lastKnownFileType = text; name = main.yml; path = .github/workflows/main.yml; sourceTree = SOURCE_ROOT; };
102-
BDC5E137236EC14200A6A467 /* Assin.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Assin.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
103+
BDB3A5A1236EF1B30041D167 /* AGRegex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AGRegex.swift; sourceTree = "<group>"; };
103104
/* End PBXFileReference section */
104105

105106
/* Begin PBXFrameworksBuildPhase section */
@@ -169,7 +170,6 @@
169170
3D9C428622745894000A6585 = {
170171
isa = PBXGroup;
171172
children = (
172-
BDC5E137236EC14200A6A467 /* Assin.playground */,
173173
3D9C42A0227458FA000A6585 /* Sources */,
174174
3D9C42A32274595F000A6585 /* Tests */,
175175
3D9C43222274629B000A6585 /* Example */,
@@ -215,7 +215,8 @@
215215
3D9C42A0227458FA000A6585 /* Sources */ = {
216216
isa = PBXGroup;
217217
children = (
218-
3D9C42A122745900000A6585 /* AGString.swift */,
218+
BDB3A5A0236EF1A20041D167 /* Regex */,
219+
BDB3A59F236EF19B0041D167 /* String */,
219220
);
220221
path = Sources;
221222
sourceTree = "<group>";
@@ -249,6 +250,22 @@
249250
path = Resources;
250251
sourceTree = "<group>";
251252
};
253+
BDB3A59F236EF19B0041D167 /* String */ = {
254+
isa = PBXGroup;
255+
children = (
256+
3D9C42A122745900000A6585 /* AGString.swift */,
257+
);
258+
path = String;
259+
sourceTree = "<group>";
260+
};
261+
BDB3A5A0236EF1A20041D167 /* Regex */ = {
262+
isa = PBXGroup;
263+
children = (
264+
BDB3A5A1236EF1B30041D167 /* AGRegex.swift */,
265+
);
266+
path = Regex;
267+
sourceTree = "<group>";
268+
};
252269
/* End PBXGroup section */
253270

254271
/* Begin PBXHeadersBuildPhase section */
@@ -636,6 +653,7 @@
636653
buildActionMask = 2147483647;
637654
files = (
638655
3D9C42A222745900000A6585 /* AGString.swift in Sources */,
656+
BDB3A5A2236EF1B30041D167 /* AGRegex.swift in Sources */,
639657
);
640658
runOnlyForDeploymentPostprocessing = 0;
641659
};

Assin.playground/Pages/Slicing.xcplaygroundpage/Contents.swift

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

Assin.playground/contents.xcplayground

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

Example/ViewController.swift

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import AGString
1515
class ViewController: UIViewController {
1616

1717
// MARK: Properties
18-
18+
1919
/// The Label
2020
lazy var label: UILabel = {
2121
let label = UILabel()
@@ -26,18 +26,103 @@ class ViewController: UIViewController {
2626
label.textAlignment = .center
2727
return label
2828
}()
29-
29+
3030
// MARK: View-Lifecycle
31-
31+
3232
/// View did load
3333
override func viewDidLoad() {
3434
super.viewDidLoad()
3535
self.view.backgroundColor = .white
36+
37+
let str = "abcde"
38+
print(str[1..<3].utf16. 1)
39+
// print(type(of: str))
40+
// print(str[1]) // => b
41+
// print(str[1..<3]) // => bc
42+
// print(str[1...3]) // => bcd
43+
// print(str[1...]) // => bcde
44+
// print(str[...3]) // => abcd
45+
// print(str[..<3]) // => abc
46+
// print("")
47+
48+
// // With substrings:
49+
// let sub = str[0...]
50+
// print(type(of: sub))
51+
// print(sub[1]) // => b
52+
// print(sub[1..<3]) // => bc
53+
// print(sub[1...3]) // => bcd
54+
// print(sub[1...]) // => bcde
55+
// print(sub[...3]) // => abcd
56+
// print(sub[..<3]) // => abc
57+
3658
}
37-
59+
3860
/// LoadView
3961
override func loadView() {
4062
self.view = self.label
4163
}
4264

4365
}
66+
67+
extension Substring {
68+
var aa: String {
69+
return String(self)
70+
}
71+
}
72+
73+
extension String {
74+
subscript (i: Int) -> Character {
75+
return self[index(startIndex, offsetBy: i)]
76+
}
77+
subscript (bounds: CountableRange<Int>) -> Substring {
78+
let start = index(startIndex, offsetBy: bounds.lowerBound)
79+
let end = index(startIndex, offsetBy: bounds.upperBound)
80+
return self[start ..< end]
81+
}
82+
subscript (bounds: CountableClosedRange<Int>) -> Substring {
83+
let start = index(startIndex, offsetBy: bounds.lowerBound)
84+
let end = index(startIndex, offsetBy: bounds.upperBound)
85+
return self[start ... end]
86+
}
87+
subscript (bounds: CountablePartialRangeFrom<Int>) -> Substring {
88+
let start = index(startIndex, offsetBy: bounds.lowerBound)
89+
let end = index(endIndex, offsetBy: -1)
90+
return self[start ... end]
91+
}
92+
subscript (bounds: PartialRangeThrough<Int>) -> Substring {
93+
let end = index(startIndex, offsetBy: bounds.upperBound)
94+
return self[startIndex ... end]
95+
}
96+
subscript (bounds: PartialRangeUpTo<Int>) -> Substring {
97+
let end = index(startIndex, offsetBy: bounds.upperBound)
98+
return self[startIndex ..< end]
99+
}
100+
}
101+
extension Substring {
102+
subscript (i: Int) -> Character {
103+
return self[index(startIndex, offsetBy: i)]
104+
}
105+
subscript (bounds: CountableRange<Int>) -> Substring {
106+
let start = index(startIndex, offsetBy: bounds.lowerBound)
107+
let end = index(startIndex, offsetBy: bounds.upperBound)
108+
return self[start ..< end]
109+
}
110+
subscript (bounds: CountableClosedRange<Int>) -> Substring {
111+
let start = index(startIndex, offsetBy: bounds.lowerBound)
112+
let end = index(startIndex, offsetBy: bounds.upperBound)
113+
return self[start ... end]
114+
}
115+
subscript (bounds: CountablePartialRangeFrom<Int>) -> Substring {
116+
let start = index(startIndex, offsetBy: bounds.lowerBound)
117+
let end = index(endIndex, offsetBy: -1)
118+
return self[start ... end]
119+
}
120+
subscript (bounds: PartialRangeThrough<Int>) -> Substring {
121+
let end = index(startIndex, offsetBy: bounds.upperBound)
122+
return self[startIndex ... end]
123+
}
124+
subscript (bounds: PartialRangeUpTo<Int>) -> Substring {
125+
let end = index(startIndex, offsetBy: bounds.upperBound)
126+
return self[startIndex ..< end]
127+
}
128+
}

Sources/Regex/AGRegex.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// AGRegex.swift
3+
// AGString-iOS
4+
//
5+
// Created by tskim on 2019/11/03.
6+
// Copyright © 2019 AGString. All rights reserved.
7+
//
8+
9+
@_exported import Foundation
10+

0 commit comments

Comments
 (0)