Skip to content

Instantly share code, notes, and snippets.

@laevandus

laevandus/FileReader.swift Secret

Created Jan 31, 2021
Embed
What would you like to do?
let fileURL = Bundle.main.url(forResource: "DataFile", withExtension: nil)!
let reader = FileReader(fileURL: fileURL)
if reader.open() {
reader.read(byteRange: 0..<20) { data in
if let data = data {
print("Read bytes: \(data.map({ UInt8($0) }))")
}
else {
print("Failed to read data")
}
}
}
else {
print("Failed to open")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment