Created
September 9, 2022 19:34
-
-
Save antonio081014/dc04fa1440613fc824311e3f1ef6362f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AsyncFileReading { | |
func asyncReadFile(_ url: URL) async throws -> Data { | |
let (data, _) = try await URLSession.shared.data(from: url) | |
return data | |
} | |
static func testout() { | |
let instance = AsyncFileReading() | |
let filename = "file_to_be_read.txt" | |
let url = Bundle.main.bundleURL.appending(component: filename) | |
Task { | |
let data = try await instance.asyncReadFile(url) | |
print(data.count) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment