What is the correct translation of this Objective C code line to Swift 4?
NSData *mappedData =
[NSData dataWithContentsOfURL:fileURL
options:NSDataReadingMappedAlways + NSDataReadingUncached
error:&error];
I tried this but it doesn't compile:
Data(contentsOf: fileUrl, options: Data.ReadingOptions.dataReadingMapped | Data.ReadingOptions.uncached)
You can try
do {
// note it runs in current thread
let data = try Data(contentsOf:fileURL, options: [.alwaysMapped , .uncached ] )
print(data)
}
catch {
print(error)
}