Skip to content

Commit

Permalink
support xcode 9.3, swift 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
psharanda committed Mar 30, 2018
1 parent 38ce41b commit 3626618
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Sources/AttributedText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,17 @@ extension AttributedTextProtocol {

public func styleLinks(_ style: Style) -> AttributedText {
let ranges = string.detect(textCheckingTypes: [.link])

#if swift(>=4.1)
let ds = ranges.compactMap { range in
URL(string: String(string[range])).map { Detection(type: .link($0), style: style, range: range) } }
URL(string: String(string[range])).map { Detection(type: .link($0), style: style, range: range) }
}
#else
let ds = ranges.flatMap { range in
URL(string: String(string[range])).map { Detection(type: .link($0), style: style, range: range) }
}
#endif

return AttributedText(string: string, detections: detections + ds, baseStyle: baseStyle)
}

Expand Down
1 change: 0 additions & 1 deletion Sources/Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public struct Style {
return merged(with: Style.writingDirection(value, type))
}



public static func font(_ value: Font, _ type: StyleType = .normal) -> Style {
return Style("", [NSAttributedStringKey.font: value], type)
Expand Down

0 comments on commit 3626618

Please sign in to comment.