writeToFile how to tell when it is completed
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)
}