Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created January 31, 2021 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/d6a386ec565e5e6778d8edcc7d18d0d7 to your computer and use it in GitHub Desktop.
Save laevandus/d6a386ec565e5e6778d8edcc7d18d0d7 to your computer and use it in GitHub Desktop.
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