我正在做一些数据写入我的文档目录,我想知道是否有办法告诉我的writeToFile方法何时完成,我创建的文件是否已完全创建.在此先感谢这里是我正在调用的方法我正在寻找一种方式,它是委托方法或其他方式告诉它何时完成.
[imageData writeToFile:fullPathToFile atomically:YES];
Run Code Online (Sandbox Code Playgroud)
缺口
sch*_*sch 33
该方法writeToFile:atomically是"同步的".它将写入文件然后返回YES或NO取决于文件是否成功写入.
这意味着一旦方法返回,操作就完成了.
BOOL success = [imageData writeToFile:fullPathToFile atomically:YES];
// Now, the operation is complete
// success indicates whether the file was successfully written or not
Run Code Online (Sandbox Code Playgroud)
斯威夫特5:
do {
try data.write(to: path)
// here's when write operation is completed without errors thrown
} catch {
Swift.print(error)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6871 次 |
| 最近记录: |