I'm doing some writing of data to my documents directory and I was wondering if there is a way to tell when my writeToFile method completes and the file I am creating has be fully created. Thanks in advance here is the method I am calling I am just looking for a way wether it is a delegate method or some other way to tell when this completes.
[imageData writeToFile:fullPathToFile atomically:YES];
Nick
The method writeToFile:atomically
is "synchronous". It will write the file and then return YES
or NO
depending on wether the file was successfully written or not.
That means that the operation is complete as soon as the method returns.
BOOL success = [imageData writeToFile:fullPathToFile atomically:YES];
// Now, the operation is complete
// success indicates whether the file was successfully written or not
Swift 5:
do {
try data.write(to: path)
// here's when write operation is completed without errors thrown
} catch {
Swift.print(error)
}
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