From aad8a8ea12a9c7ef8c419c4b3b0e34aedbae7c05 Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Sun, 2 Jul 2017 22:30:36 -0500 Subject: [PATCH] Swift 4 support --- ShareClient/ShareClient.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ShareClient/ShareClient.swift b/ShareClient/ShareClient.swift index d5fcda8..5f23358 100644 --- a/ShareClient/ShareClient.swift +++ b/ShareClient/ShareClient.swift @@ -206,9 +206,14 @@ public class ShareClient { private func parseDate(_ wt: String) throws -> Date { // wt looks like "/Date(1462404576000)/" - let re = try NSRegularExpression(pattern: "\\((.*)\\)", options: []) - if let match = re.firstMatch(in: wt, options: [], range: NSMakeRange(0, wt.characters.count)) { - let epoch = Double((wt as NSString).substring(with: match.rangeAt(1)))! / 1000 + let re = try NSRegularExpression(pattern: "\\((.*)\\)") + if let match = re.firstMatch(in: wt, range: NSMakeRange(0, wt.characters.count)) { + #if swift(>=4) + let matchRange = match.range(at: 1) + #else + let matchRange = match.rangeAt(1) + #endif + let epoch = Double((wt as NSString).substring(with: matchRange))! / 1000 return Date(timeIntervalSince1970: epoch) } else { throw ShareError.dateError