prepare for async work
This commit is contained in:
committed by
Felix Förtsch
parent
e72b0f3aba
commit
3b8c44d233
@@ -9,10 +9,6 @@
|
||||
import Foundation
|
||||
import SwiftSoup
|
||||
|
||||
protocol MatchesAPIDelegate {
|
||||
|
||||
}
|
||||
|
||||
class MatchesAPI {
|
||||
|
||||
func fetchMatches(for game: String) -> [Match]? {
|
||||
@@ -26,13 +22,9 @@ class MatchesAPI {
|
||||
|
||||
private func fetchData(for game: String) -> String? {
|
||||
let url = constructURL(for: game)
|
||||
// DispatchQueue.global().async { [unowned self] in
|
||||
if let url = URL(string: url) {
|
||||
if let data = try? String(contentsOf: url) {
|
||||
return data
|
||||
}
|
||||
}
|
||||
// }
|
||||
if let data = try? String(contentsOf: url) {
|
||||
return data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -73,10 +65,10 @@ class MatchesAPI {
|
||||
}
|
||||
}
|
||||
|
||||
private func constructURL(for game: String) -> String {
|
||||
private func constructURL(for game: String) -> URL {
|
||||
let baseURL = "https://liquipedia.net/"
|
||||
let query = "/api.php?action=parse&page=Liquipedia:Upcoming_and_ongoing_matches&format=json&prop=text"
|
||||
return baseURL + game + query
|
||||
return URL(string: baseURL + game + query)!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user