Skip to content

Commit 8213bc6

Browse files
author
Hilen
committed
Swift 4 compatibility
1 parent c72c36f commit 8213bc6

16 files changed

+97
-76
lines changed

.swift-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.0

Demo/Podfile.lock

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
PODS:
2-
- TimedSilver (0.1.1)
2+
- TimedSilver (1.1.0)
33

44
DEPENDENCIES:
55
- TimedSilver (from `../`)
66

77
EXTERNAL SOURCES:
88
TimedSilver:
9-
:path: ../
9+
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
TimedSilver: 56137f4a9f7ee4bb07e3f7a9833691e5c4beb983
12+
TimedSilver: 9a4db36b50fe8dd2f76ec28a1d5b6f0e98f6bb30
1313

14-
COCOAPODS: 0.39.0
14+
PODFILE CHECKSUM: 416a9304df26078601f30ee2451b2f3dbe8abf38
15+
16+
COCOAPODS: 1.2.0

Demo/TimedSilverExample.xcodeproj/project.pbxproj

+49-33
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
6640AF2AC6CA686EB97CB29B /* Pods_TimedSilverExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C667354C03077DB65A58E241 /* Pods_TimedSilverExample.framework */; };
1011
AEBAE9401D8E8AF200CFDBD5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBAE93F1D8E8AF200CFDBD5 /* AppDelegate.swift */; };
1112
AEBAE9421D8E8AF200CFDBD5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBAE9411D8E8AF200CFDBD5 /* ViewController.swift */; };
1213
AEBAE9451D8E8AF200CFDBD5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AEBAE9431D8E8AF200CFDBD5 /* Main.storyboard */; };
1314
AEBAE9471D8E8AF200CFDBD5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AEBAE9461D8E8AF200CFDBD5 /* Assets.xcassets */; };
1415
AEBAE94A1D8E8AF200CFDBD5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AEBAE9481D8E8AF200CFDBD5 /* LaunchScreen.storyboard */; };
1516
AEBAE9551D8E8AF200CFDBD5 /* TimedSilverExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBAE9541D8E8AF200CFDBD5 /* TimedSilverExampleTests.swift */; };
16-
F3B884ECE2427EB04D2A3DC5 /* Pods_TimedSilverExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B9D3E48314E78737066C491 /* Pods_TimedSilverExample.framework */; };
1717
/* End PBXBuildFile section */
1818

1919
/* Begin PBXContainerItemProxy section */
@@ -27,9 +27,8 @@
2727
/* End PBXContainerItemProxy section */
2828

2929
/* Begin PBXFileReference section */
30-
71CF4986250D365A62A131F6 /* Pods-TimedSilverExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TimedSilverExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample.release.xcconfig"; sourceTree = "<group>"; };
31-
7B9D3E48314E78737066C491 /* Pods_TimedSilverExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TimedSilverExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
32-
829DD242BE8471F96F3FD65C /* Pods-TimedSilverExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TimedSilverExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample.debug.xcconfig"; sourceTree = "<group>"; };
30+
74904B260662CC4D85CA4568 /* Pods-TimedSilverExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TimedSilverExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample.debug.xcconfig"; sourceTree = "<group>"; };
31+
96DEBC55B60AFCE4512BCF98 /* Pods-TimedSilverExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TimedSilverExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample.release.xcconfig"; sourceTree = "<group>"; };
3332
AEBAE93C1D8E8AF200CFDBD5 /* TimedSilverExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TimedSilverExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
3433
AEBAE93F1D8E8AF200CFDBD5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3534
AEBAE9411D8E8AF200CFDBD5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@@ -40,14 +39,15 @@
4039
AEBAE9501D8E8AF200CFDBD5 /* TimedSilverExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TimedSilverExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4140
AEBAE9541D8E8AF200CFDBD5 /* TimedSilverExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimedSilverExampleTests.swift; sourceTree = "<group>"; };
4241
AEBAE9561D8E8AF200CFDBD5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
42+
C667354C03077DB65A58E241 /* Pods_TimedSilverExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TimedSilverExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4343
/* End PBXFileReference section */
4444

4545
/* Begin PBXFrameworksBuildPhase section */
4646
AEBAE9391D8E8AF200CFDBD5 /* Frameworks */ = {
4747
isa = PBXFrameworksBuildPhase;
4848
buildActionMask = 2147483647;
4949
files = (
50-
F3B884ECE2427EB04D2A3DC5 /* Pods_TimedSilverExample.framework in Frameworks */,
50+
6640AF2AC6CA686EB97CB29B /* Pods_TimedSilverExample.framework in Frameworks */,
5151
);
5252
runOnlyForDeploymentPostprocessing = 0;
5353
};
@@ -61,13 +61,12 @@
6161
/* End PBXFrameworksBuildPhase section */
6262

6363
/* Begin PBXGroup section */
64-
2CA1DF2484E33BAFD69880F1 /* Pods */ = {
64+
9F8718EE01F821E5C854F8F6 /* Frameworks */ = {
6565
isa = PBXGroup;
6666
children = (
67-
829DD242BE8471F96F3FD65C /* Pods-TimedSilverExample.debug.xcconfig */,
68-
71CF4986250D365A62A131F6 /* Pods-TimedSilverExample.release.xcconfig */,
67+
C667354C03077DB65A58E241 /* Pods_TimedSilverExample.framework */,
6968
);
70-
name = Pods;
69+
name = Frameworks;
7170
sourceTree = "<group>";
7271
};
7372
AEBAE9331D8E8AF200CFDBD5 = {
@@ -76,8 +75,8 @@
7675
AEBAE93E1D8E8AF200CFDBD5 /* TimedSilverExample */,
7776
AEBAE9531D8E8AF200CFDBD5 /* TimedSilverExampleTests */,
7877
AEBAE93D1D8E8AF200CFDBD5 /* Products */,
79-
2CA1DF2484E33BAFD69880F1 /* Pods */,
80-
C29E39200D01CC9351A7EB70 /* Frameworks */,
78+
D47055B4FC0570C764FE0D24 /* Pods */,
79+
9F8718EE01F821E5C854F8F6 /* Frameworks */,
8180
);
8281
sourceTree = "<group>";
8382
};
@@ -112,12 +111,13 @@
112111
path = TimedSilverExampleTests;
113112
sourceTree = "<group>";
114113
};
115-
C29E39200D01CC9351A7EB70 /* Frameworks */ = {
114+
D47055B4FC0570C764FE0D24 /* Pods */ = {
116115
isa = PBXGroup;
117116
children = (
118-
7B9D3E48314E78737066C491 /* Pods_TimedSilverExample.framework */,
117+
74904B260662CC4D85CA4568 /* Pods-TimedSilverExample.debug.xcconfig */,
118+
96DEBC55B60AFCE4512BCF98 /* Pods-TimedSilverExample.release.xcconfig */,
119119
);
120-
name = Frameworks;
120+
name = Pods;
121121
sourceTree = "<group>";
122122
};
123123
/* End PBXGroup section */
@@ -127,12 +127,12 @@
127127
isa = PBXNativeTarget;
128128
buildConfigurationList = AEBAE9591D8E8AF200CFDBD5 /* Build configuration list for PBXNativeTarget "TimedSilverExample" */;
129129
buildPhases = (
130-
F3536D336CE396E39A57E469 /* Check Pods Manifest.lock */,
130+
0249506483674692E9C1309A /* [CP] Check Pods Manifest.lock */,
131131
AEBAE9381D8E8AF200CFDBD5 /* Sources */,
132132
AEBAE9391D8E8AF200CFDBD5 /* Frameworks */,
133133
AEBAE93A1D8E8AF200CFDBD5 /* Resources */,
134-
CD04BFB02355E7694C064855 /* Embed Pods Frameworks */,
135-
F0ED6F48A43F8B623CCC6510 /* Copy Pods Resources */,
134+
ED52BC296B9EF83249163349 /* [CP] Embed Pods Frameworks */,
135+
201A5143EF5307CE6CDE43D3 /* [CP] Copy Pods Resources */,
136136
);
137137
buildRules = (
138138
);
@@ -168,7 +168,7 @@
168168
isa = PBXProject;
169169
attributes = {
170170
LastSwiftUpdateCheck = 0800;
171-
LastUpgradeCheck = 0800;
171+
LastUpgradeCheck = 0910;
172172
ORGANIZATIONNAME = Hilen;
173173
TargetAttributes = {
174174
AEBAE93B1D8E8AF200CFDBD5 = {
@@ -178,7 +178,7 @@
178178
};
179179
AEBAE94F1D8E8AF200CFDBD5 = {
180180
CreatedOnToolsVersion = 8.0;
181-
LastSwiftMigration = 0800;
181+
LastSwiftMigration = 0910;
182182
ProvisioningStyle = Automatic;
183183
TestTargetID = AEBAE93B1D8E8AF200CFDBD5;
184184
};
@@ -224,49 +224,49 @@
224224
/* End PBXResourcesBuildPhase section */
225225

226226
/* Begin PBXShellScriptBuildPhase section */
227-
CD04BFB02355E7694C064855 /* Embed Pods Frameworks */ = {
227+
0249506483674692E9C1309A /* [CP] Check Pods Manifest.lock */ = {
228228
isa = PBXShellScriptBuildPhase;
229229
buildActionMask = 2147483647;
230230
files = (
231231
);
232232
inputPaths = (
233233
);
234-
name = "Embed Pods Frameworks";
234+
name = "[CP] Check Pods Manifest.lock";
235235
outputPaths = (
236236
);
237237
runOnlyForDeploymentPostprocessing = 0;
238238
shellPath = /bin/sh;
239-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-frameworks.sh\"\n";
239+
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
240240
showEnvVarsInLog = 0;
241241
};
242-
F0ED6F48A43F8B623CCC6510 /* Copy Pods Resources */ = {
242+
201A5143EF5307CE6CDE43D3 /* [CP] Copy Pods Resources */ = {
243243
isa = PBXShellScriptBuildPhase;
244244
buildActionMask = 2147483647;
245245
files = (
246246
);
247247
inputPaths = (
248248
);
249-
name = "Copy Pods Resources";
249+
name = "[CP] Copy Pods Resources";
250250
outputPaths = (
251251
);
252252
runOnlyForDeploymentPostprocessing = 0;
253253
shellPath = /bin/sh;
254254
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-resources.sh\"\n";
255255
showEnvVarsInLog = 0;
256256
};
257-
F3536D336CE396E39A57E469 /* Check Pods Manifest.lock */ = {
257+
ED52BC296B9EF83249163349 /* [CP] Embed Pods Frameworks */ = {
258258
isa = PBXShellScriptBuildPhase;
259259
buildActionMask = 2147483647;
260260
files = (
261261
);
262262
inputPaths = (
263263
);
264-
name = "Check Pods Manifest.lock";
264+
name = "[CP] Embed Pods Frameworks";
265265
outputPaths = (
266266
);
267267
runOnlyForDeploymentPostprocessing = 0;
268268
shellPath = /bin/sh;
269-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
269+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-frameworks.sh\"\n";
270270
showEnvVarsInLog = 0;
271271
};
272272
/* End PBXShellScriptBuildPhase section */
@@ -328,15 +328,22 @@
328328
CLANG_CXX_LIBRARY = "libc++";
329329
CLANG_ENABLE_MODULES = YES;
330330
CLANG_ENABLE_OBJC_ARC = YES;
331+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
331332
CLANG_WARN_BOOL_CONVERSION = YES;
333+
CLANG_WARN_COMMA = YES;
332334
CLANG_WARN_CONSTANT_CONVERSION = YES;
333335
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
334336
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
335337
CLANG_WARN_EMPTY_BODY = YES;
336338
CLANG_WARN_ENUM_CONVERSION = YES;
337339
CLANG_WARN_INFINITE_RECURSION = YES;
338340
CLANG_WARN_INT_CONVERSION = YES;
341+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
342+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
339343
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
344+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
345+
CLANG_WARN_STRICT_PROTOTYPES = YES;
346+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
340347
CLANG_WARN_SUSPICIOUS_MOVES = YES;
341348
CLANG_WARN_UNREACHABLE_CODE = YES;
342349
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -377,15 +384,22 @@
377384
CLANG_CXX_LIBRARY = "libc++";
378385
CLANG_ENABLE_MODULES = YES;
379386
CLANG_ENABLE_OBJC_ARC = YES;
387+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
380388
CLANG_WARN_BOOL_CONVERSION = YES;
389+
CLANG_WARN_COMMA = YES;
381390
CLANG_WARN_CONSTANT_CONVERSION = YES;
382391
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
383392
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
384393
CLANG_WARN_EMPTY_BODY = YES;
385394
CLANG_WARN_ENUM_CONVERSION = YES;
386395
CLANG_WARN_INFINITE_RECURSION = YES;
387396
CLANG_WARN_INT_CONVERSION = YES;
397+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
398+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
388399
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
400+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
401+
CLANG_WARN_STRICT_PROTOTYPES = YES;
402+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
389403
CLANG_WARN_SUSPICIOUS_MOVES = YES;
390404
CLANG_WARN_UNREACHABLE_CODE = YES;
391405
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -412,27 +426,27 @@
412426
};
413427
AEBAE95A1D8E8AF200CFDBD5 /* Debug */ = {
414428
isa = XCBuildConfiguration;
415-
baseConfigurationReference = 829DD242BE8471F96F3FD65C /* Pods-TimedSilverExample.debug.xcconfig */;
429+
baseConfigurationReference = 74904B260662CC4D85CA4568 /* Pods-TimedSilverExample.debug.xcconfig */;
416430
buildSettings = {
417431
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
418432
INFOPLIST_FILE = TimedSilverExample/Info.plist;
419433
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
420434
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExample;
421435
PRODUCT_NAME = "$(TARGET_NAME)";
422-
SWIFT_VERSION = 3.0;
436+
SWIFT_VERSION = 4.0;
423437
};
424438
name = Debug;
425439
};
426440
AEBAE95B1D8E8AF200CFDBD5 /* Release */ = {
427441
isa = XCBuildConfiguration;
428-
baseConfigurationReference = 71CF4986250D365A62A131F6 /* Pods-TimedSilverExample.release.xcconfig */;
442+
baseConfigurationReference = 96DEBC55B60AFCE4512BCF98 /* Pods-TimedSilverExample.release.xcconfig */;
429443
buildSettings = {
430444
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
431445
INFOPLIST_FILE = TimedSilverExample/Info.plist;
432446
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
433447
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExample;
434448
PRODUCT_NAME = "$(TARGET_NAME)";
435-
SWIFT_VERSION = 3.0;
449+
SWIFT_VERSION = 4.0;
436450
};
437451
name = Release;
438452
};
@@ -445,7 +459,8 @@
445459
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
446460
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExampleTests;
447461
PRODUCT_NAME = "$(TARGET_NAME)";
448-
SWIFT_VERSION = 3.0;
462+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
463+
SWIFT_VERSION = 4.0;
449464
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TimedSilverExample.app/TimedSilverExample";
450465
};
451466
name = Debug;
@@ -459,7 +474,8 @@
459474
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
460475
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExampleTests;
461476
PRODUCT_NAME = "$(TARGET_NAME)";
462-
SWIFT_VERSION = 3.0;
477+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
478+
SWIFT_VERSION = 4.0;
463479
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TimedSilverExample.app/TimedSilverExample";
464480
};
465481
name = Release;

Sources/Foundation/NotificationCenter+TSBlock.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ private func ts_observationRemoversForObject(_ object: AnyObject) -> NSMutableAr
6262
}
6363
}
6464

65-
var retainedRemovers = objc_getAssociatedObject(object, TSObservationRemoverKey) as! NSMutableArray?
65+
var retainedRemovers = objc_getAssociatedObject(object, TSObservationRemoverKey!) as! NSMutableArray?
6666
if retainedRemovers == nil {
6767
retainedRemovers = NSMutableArray()
68-
objc_setAssociatedObject(object, TSObservationRemoverKey, retainedRemovers, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
68+
objc_setAssociatedObject(object, TSObservationRemoverKey!, retainedRemovers, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
6969
}
7070
return retainedRemovers!
7171
}

Sources/Foundation/URLRequest+TScURLCommand.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111

1212
extension URLRequest {
1313
fileprivate func escapeQuotesInString(_ string: String) -> String {
14-
assert(string.characters.count > 0 , "Error: String is not valid")
14+
assert(string.count > 0 , "Error: String is not valid")
1515
return string.replacingOccurrences(of: "\"", with:"\\\"", options: NSString.CompareOptions.literal, range: nil)
1616
}
1717

@@ -53,7 +53,7 @@ extension URLRequest {
5353

5454
if let body: Data = self.httpBody , self.httpBody != nil {
5555
if var bodyDataString = String(data: body, encoding: String.Encoding.utf8) {
56-
if bodyDataString.characters.count > 0 {
56+
if bodyDataString.count > 0 {
5757
bodyDataString = self.escapeQuotesInString(bodyDataString)
5858
curlString.appendFormat(" -d \"%@\"", bodyDataString)
5959
}

Sources/Struct/String+TSExtension.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import UIKit
1313
public extension String {
1414
/// String's length
1515
var ts_length: Int {
16-
return self.characters.count
16+
return self.count
1717
}
1818

1919
/**
@@ -29,7 +29,7 @@ public extension String {
2929
let size: CGSize = self.boundingRect(
3030
with: constraintRect,
3131
options: NSStringDrawingOptions.usesLineFragmentOrigin,
32-
attributes: [NSFontAttributeName: font],
32+
attributes: [NSAttributedStringKey.font: font],
3333
context: nil
3434
).size
3535
return size
@@ -48,7 +48,7 @@ public extension String {
4848
let boundingBox = self.boundingRect(
4949
with: constraintRect,
5050
options: .usesLineFragmentOrigin,
51-
attributes: [NSFontAttributeName: font],
51+
attributes: [NSAttributedStringKey.font: font],
5252
context: nil)
5353
return boundingBox.height
5454
}
@@ -65,7 +65,7 @@ public extension String {
6565
let boundingBox = self.boundingRect(
6666
with: constraintRect,
6767
options: .usesLineFragmentOrigin,
68-
attributes: [NSFontAttributeName: font],
68+
attributes: [NSAttributedStringKey.font: font],
6969
context: nil)
7070
return boundingBox.width
7171
}
@@ -83,8 +83,8 @@ public extension String {
8383
let from = range.lowerBound
8484
let to = range.upperBound
8585

86-
let location = characters.distance(from: startIndex, to: from)
87-
let length = characters.distance(from: from, to: to)
86+
let location = self.distance(from: startIndex, to: from)
87+
let length = self.distance(from: from, to: to)
8888

8989
return NSRange(location: location, length: length)
9090
}

Sources/UIKit/UIColor+TSExtension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public extension UIColor {
2323
var int = UInt32()
2424
Scanner(string: hex).scanHexInt32(&int)
2525
let r, g, b: UInt32
26-
switch hex.characters.count {
26+
switch hex.count {
2727
case 3: // RGB (12-bit)
2828
(r, g, b) = ((int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
2929
case 6: // RGB (24-bit)

0 commit comments

Comments
 (0)