I am converting code into swift 3 syntax
if !data.writeToURL(manifestFileURL, atomically: false) {
self.didFailWithError(WebAppError.fileSystemFailure(reason: "Could not write asset manifest to: \(manifestFileURL)", underlyingError: error))
return
}
but I am getting the error
Value of type 'Data' has no member 'writeToURL'
I have converted the code to
if try!data.write(to: manifestFileURL, atomically: false) {
self.didFailWithError(WebAppError.fileSystemFailure(reason: "Could not write asset manifest to: \(manifestFileURL)", underlyingError: error))
return
}
following the swift 3 syntax and current methods (https://developer.apple.com/reference/foundation/nsdata/1415134-write) but I get errors saying that this is not the correct overload for the function. Please, what is the correct way to write this out in swift 3. Any information that can lead me in the right direction will be greatly appreciated.
Thanks
atomically: false is equal to no options, you can omit the parameter.
So it's simply
do {
try data.write(to: manifestFileURL)
} catch let error as NSError {
self.didFailWithError(WebAppError.fileSystemFailure(reason: "Could not write asset manifest to: \(manifestFileURL)", underlyingError: error))
}
The catch clause handles the error.
It has been rename to:
try! data.write(to: manifestFileURL, options: [.atomic])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With