Skip to content

Commit e2f569a

Browse files
author
Hilen
committed
Rename files and fix syntax error
1 parent 2c7a232 commit e2f569a

18 files changed

+152
-35
lines changed

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0

Package.swift

Whitespace-only changes.

Sources/Foundation/NSData+TSExtension.swift renamed to Sources/Foundation/Data+TSExtension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NSData+TSExtension.swift
2+
// Data+TSExtension.swift
33
// TimedSilver
44
// Source: https://github.com/hilen/TimedSilver
55
//

Sources/Foundation/NSDate+TSExtension.swift renamed to Sources/Foundation/Date+TSExtension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NSDate+TSExtension.swift
2+
// Date+TSExtension.swift
33
// TimedSilver
44
// Source: https://github.com/hilen/TimedSilver
55
//

Sources/Foundation/NSFileManager+TSExtension.swift renamed to Sources/Foundation/FileManager+TSExtension.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NSFileManager+TSExtension.swift
2+
// FileManager+TSExtension.swift
33
// TimedSilver
44
// Source: https://github.com/hilen/TimedSilver
55
//
@@ -70,9 +70,10 @@ public extension FileManager {
7070
- parameter filePath: Path to a file to set an attribute.
7171
*/
7272
class func ts_addSkipBackupAttributeToFile(_ filePath: String) {
73-
if let url: URL = URL(fileURLWithPath: filePath) {
74-
do { try (url as NSURL).setResourceValue(NSNumber(value: true as Bool), forKey: URLResourceKey.isExcludedFromBackupKey) } catch {}
75-
}
73+
let url: URL = URL(fileURLWithPath: filePath)
74+
do {
75+
try (url as NSURL).setResourceValue(NSNumber(value: true as Bool), forKey: URLResourceKey.isExcludedFromBackupKey)
76+
} catch {}
7677
}
7778

7879
/**

Sources/Foundation/NSIndexPath+TSOffset.swift renamed to Sources/Foundation/IndexPath+TSOffset.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NSIndexPath+TSOffset.swift
2+
// IndexPath+TSOffset.swift
33
// TimedSilver
44
// Source: https://github.com/hilen/TimedSilver
55
//

Sources/Foundation/NSBundle+TSExtension.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// Copyright © 2016 Hilen. All rights reserved.
88
//
99

10+
import Foundation
1011
import UIKit
1112

1213
public extension Bundle {

Sources/Foundation/NSIndexSet+TSExtension.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import Foundation
2222
public extension NSIndexSet {
2323
func ts_indexPathsFromIndexes(section: NSInteger) -> [NSIndexPath] {
2424
var indexPaths = [NSIndexPath]()
25-
self.enumerateIndexesUsingBlock { index, stop in
25+
self.enumerate { index, stop in
2626
let path = NSIndexPath(forItem: index, inSection: section)
2727
indexPaths.append(path)
2828
}
2929
return indexPaths
3030
}
31-
}
31+
}

Sources/Foundation/NSRange+TSExtension.swift

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,120 @@
1010
import Foundation
1111

1212
public extension NSRange {
13+
/**
14+
Init with location and length
15+
16+
- parameter ts_location: location
17+
- parameter ts_length: length
18+
19+
- returns: NSRange
20+
*/
1321
init(ts_location:Int, ts_length:Int) {
1422
self.location = ts_location
1523
self.length = ts_length
1624
}
1725

18-
init(_ location:Int, _ length:Int) {
19-
self.location = location
20-
self.length = length
26+
/**
27+
Init with location and length
28+
29+
- parameter ts_location: location
30+
- parameter ts_length: length
31+
32+
- returns: NSRange
33+
*/
34+
init(_ ts_location:Int, _ ts_length:Int) {
35+
self.location = ts_location
36+
self.length = ts_length
2137
}
2238

39+
/**
40+
Init from Range
41+
42+
- parameter ts_range: Range
43+
44+
- returns: NSRange
45+
*/
2346
init(ts_range:Range <Int>) {
2447
self.location = ts_range.lowerBound
2548
self.length = ts_range.upperBound - ts_range.lowerBound
2649
}
2750

28-
init(_ range:Range <Int>) {
29-
self.location = range.lowerBound
30-
self.length = range.upperBound - range.lowerBound
51+
/**
52+
Init from Range
53+
54+
- parameter ts_range: Range
55+
56+
- returns: NSRange
57+
*/
58+
init(_ ts_range:Range <Int>) {
59+
self.location = ts_range.lowerBound
60+
self.length = ts_range.upperBound - ts_range.lowerBound
3161
}
3262

63+
64+
/// Get NSRange start index
3365
var ts_startIndex:Int { get { return location } }
66+
67+
/// Get NSRange end index
3468
var ts_endIndex:Int { get { return location + length } }
69+
70+
/// Convert NSRange to Range
3571
var ts_asRange:Range<Int> { get { return location..<location + length } }
72+
73+
/// Check empty
3674
var ts_isEmpty:Bool { get { return length == 0 } }
3775

76+
/**
77+
Check NSRange contains index
78+
79+
- parameter index: index
80+
81+
- returns: Bool
82+
*/
3883
func ts_contains(index:Int) -> Bool {
3984
return index >= location && index < ts_endIndex
4085
}
4186

87+
/**
88+
Get NSRange's clamp Index
89+
90+
- parameter index: index
91+
92+
- returns: Bool
93+
*/
4294
func ts_clamp(index:Int) -> Int {
4395
return max(self.ts_startIndex, min(self.ts_endIndex - 1, index))
4496
}
4597

98+
/**
99+
Check NSRange intersects another NSRange
100+
101+
- parameter range: NSRange
102+
103+
- returns: Bool
104+
*/
46105
func ts_intersects(range:NSRange) -> Bool {
47106
return NSIntersectionRange(self, range).ts_isEmpty == false
48107
}
49108

109+
/**
110+
Get the two NSRange's intersection
111+
112+
- parameter range: NSRange
113+
114+
- returns: NSRange
115+
*/
50116
func ts_intersection(range:NSRange) -> NSRange {
51117
return NSIntersectionRange(self, range)
52118
}
53119

120+
/**
121+
Get the two NSRange's union value
122+
123+
- parameter range: NSRange
124+
125+
- returns: NSRange
126+
*/
54127
func ts_union(range:NSRange) -> NSRange {
55128
return NSUnionRange(self, range)
56129
}

0 commit comments

Comments
 (0)