From c292e921947366ee234956d37bdb18cf67f07777 Mon Sep 17 00:00:00 2001 From: Lumaa Date: Sun, 23 Jun 2024 16:17:52 +0200 Subject: [PATCH] Warning fixed --- Threaded/Data/Instance.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Threaded/Data/Instance.swift b/Threaded/Data/Instance.swift index 9889a57..fd49126 100644 --- a/Threaded/Data/Instance.swift +++ b/Threaded/Data/Instance.swift @@ -6,7 +6,7 @@ public struct Instance: Codable, Sendable { static let blocklistUrl: URL? = URL(string: "https://codeberg.org/oliphant/blocklists/raw/branch/main/blocklists/_unified_tier0_blocklist.csv") @MainActor - static func getBlocklist() -> [String] { + static func getBlocklist() async -> [String] { var final: [String] = [] //locate the file you want to use guard let filelink = Instance.blocklistUrl else { @@ -14,16 +14,17 @@ public struct Instance: Codable, Sendable { } //convert that file into one long string - var data = "" + var string = "" do { - data = try String(contentsOf: filelink) + let data = try await URLSession.shared.data(from: filelink).0 + string = String(data: data, encoding: .utf8) ?? "" } catch { print(error) return [] } //now split that string into an array of "rows" of data. Each row is a string. - var rows = data.components(separatedBy: "\n") + var rows = string.components(separatedBy: "\n") //if you have a header row, remove it here rows.removeFirst()