Skip to content

Commit aad8a8e

Browse files
committed
Swift 4 support
1 parent 72b370f commit aad8a8e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ShareClient/ShareClient.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,14 @@ public class ShareClient {
206206

207207
private func parseDate(_ wt: String) throws -> Date {
208208
// wt looks like "/Date(1462404576000)/"
209-
let re = try NSRegularExpression(pattern: "\\((.*)\\)", options: [])
210-
if let match = re.firstMatch(in: wt, options: [], range: NSMakeRange(0, wt.characters.count)) {
211-
let epoch = Double((wt as NSString).substring(with: match.rangeAt(1)))! / 1000
209+
let re = try NSRegularExpression(pattern: "\\((.*)\\)")
210+
if let match = re.firstMatch(in: wt, range: NSMakeRange(0, wt.characters.count)) {
211+
#if swift(>=4)
212+
let matchRange = match.range(at: 1)
213+
#else
214+
let matchRange = match.rangeAt(1)
215+
#endif
216+
let epoch = Double((wt as NSString).substring(with: matchRange))! / 1000
212217
return Date(timeIntervalSince1970: epoch)
213218
} else {
214219
throw ShareError.dateError

0 commit comments

Comments
 (0)