diff --git a/Sources/WKZombie/HTMLPage.swift b/Sources/WKZombie/HTMLPage.swift
index 7d8dfdf..8ffd858 100644
--- a/Sources/WKZombie/HTMLPage.swift
+++ b/Sources/WKZombie/HTMLPage.swift
@@ -52,7 +52,7 @@ public class HTMLPage : HTMLParser, Page {
public func findElements(_ searchType: SearchType) -> Result<[T]> {
let query = searchType.xPathQuery()
if let parsedObjects = searchWithXPathQuery(query) , parsedObjects.count > 0 {
- return resultFromOptional(parsedObjects.flatMap { T(element: $0, XPathQuery: query) }, error: .notFound)
+ return resultFromOptional(parsedObjects.compactMap { T(element: $0, XPathQuery: query) }, error: .notFound)
}
return Result.error(.notFound)
}
diff --git a/Sources/WKZombie/Parser.swift b/Sources/WKZombie/Parser.swift
index cbc0e2c..7a56fc7 100644
--- a/Sources/WKZombie/Parser.swift
+++ b/Sources/WKZombie/Parser.swift
@@ -109,11 +109,11 @@ public class HTMLParserElement : CustomStringConvertible {
}
public func childrenWithTagName(_ tagName: String) -> [T]? {
- return element?.children(withTagName: tagName).flatMap { T(element: $0 as AnyObject) }
+ return element?.children(withTagName: tagName).compactMap { T(element: $0 as AnyObject) }
}
public func children() -> [T]? {
- return element?.children.flatMap { T(element:$0 as AnyObject) }
+ return element?.children.compactMap { T(element:$0 as AnyObject) }
}
public func hasChildren() -> Bool {
diff --git a/Sources/WKZombie/RenderOperation.swift b/Sources/WKZombie/RenderOperation.swift
index 81a8682..7566ecf 100644
--- a/Sources/WKZombie/RenderOperation.swift
+++ b/Sources/WKZombie/RenderOperation.swift
@@ -113,7 +113,7 @@ internal class RenderOperation : Operation {
func wait(_ condition: () -> Bool) {
let updateInterval : TimeInterval = 0.1
var loopUntil = Date(timeIntervalSinceNow: updateInterval)
- while condition() == false && RunLoop.current.run(mode: RunLoopMode.defaultRunLoopMode, before: loopUntil) {
+ while condition() == false && RunLoop.current.run(mode: RunLoop.Mode.default, before: loopUntil) {
loopUntil = Date(timeIntervalSinceNow: updateInterval)
Logger.log(".", lineBreak: false)
}
@@ -149,7 +149,7 @@ internal class RenderOperation : Operation {
fileprivate func startTimeout() {
stopRunLoop = false
timeout = Timer(timeInterval: timeoutInSeconds, target: self, selector: #selector(RenderOperation.cancel), userInfo: nil, repeats: false)
- RunLoop.current.add(timeout!, forMode: RunLoopMode.defaultRunLoopMode)
+ RunLoop.current.add(timeout!, forMode: RunLoop.Mode.default)
}
fileprivate func stopTimeout() {
diff --git a/Sources/WKZombie/Renderer.swift b/Sources/WKZombie/Renderer.swift
index 384f8c7..d478733 100644
--- a/Sources/WKZombie/Renderer.swift
+++ b/Sources/WKZombie/Renderer.swift
@@ -224,7 +224,7 @@ extension Renderer {
let snapshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
- if let data = UIImagePNGRepresentation(snapshot!) {
+ if let data = snapshot!.pngData() {
return Snapshot(data: data, page: webView.url)
}
return nil