From 4484a2e2d0ef40ca87bc16741a4b59a41dabdac9 Mon Sep 17 00:00:00 2001 From: Fatih Nayebi Date: Sat, 17 Mar 2018 16:03:59 -0400 Subject: [PATCH 1/2] 'characters' is deprecated issue fixed --- Sources/Lingo/StringInterpolator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Lingo/StringInterpolator.swift b/Sources/Lingo/StringInterpolator.swift index b94d7bf..a44771f 100644 --- a/Sources/Lingo/StringInterpolator.swift +++ b/Sources/Lingo/StringInterpolator.swift @@ -9,7 +9,7 @@ class StringInterpolator { func interpolate(_ rawString: String, with interpolations: [String: Any]) -> String { var result = rawString - let matches = StringInterpolator.regularExpression.matches(in: rawString, options: [], range: NSRange.init(location: 0, length: rawString.characters.count)) + let matches = StringInterpolator.regularExpression.matches(in: rawString, options: [], range: NSRange.init(location: 0, length: rawString.count)) for match in matches { let range: NSRange = match.range From c6e70a4021115ce66fbaa0ada26072d5dcfb9ed8 Mon Sep 17 00:00:00 2001 From: Fatih Nayebi Date: Sat, 17 Mar 2018 18:56:44 -0400 Subject: [PATCH 2/2] Swift version check to support < v4 syntax --- Sources/Lingo/StringInterpolator.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/Lingo/StringInterpolator.swift b/Sources/Lingo/StringInterpolator.swift index a44771f..28de6cc 100644 --- a/Sources/Lingo/StringInterpolator.swift +++ b/Sources/Lingo/StringInterpolator.swift @@ -8,9 +8,11 @@ class StringInterpolator { /// The function finds all placeholders and replaces them with a value specified in interpolations dictionary func interpolate(_ rawString: String, with interpolations: [String: Any]) -> String { var result = rawString - - let matches = StringInterpolator.regularExpression.matches(in: rawString, options: [], range: NSRange.init(location: 0, length: rawString.count)) - + #if swift(>=4) + let matches = StringInterpolator.regularExpression.matches(in: rawString, options: [], range: NSRange.init(location: 0, length: rawString.count)) + #else + let matches = StringInterpolator.regularExpression.matches(in: rawString, options: [], range: NSRange.init(location: 0, length: rawString.characters.count)) + #endif for match in matches { let range: NSRange = match.range