我正在编写专门针对 MountainLion 的代码,因此我想尽量避免使用已弃用的 API。
我使用FSFileOperationCreate接收有关复制进度的信息(kFSOperationBytesCompleteKey、kFSOperationThroughputKey、kFSOperationTotalBytesKey),但文档显示
Creates an object that represents an asynchronous file operation. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)
使用 copyItemAtURL:toURL:error 和 NSFileManagerDelegate似乎不可能获得相同的信息。
如何在 10.8 中获得相同的行为而不需要自己重写代码?
苹果现在知道制造同样的东西是简单而可怕的吗?
最佳答案
可能不是您希望听到的答案[1],但是将 copyfile(3)
包装在您自己的 Obj-C 包装器中。您应该能够使用回调计算所需的所有内容,特别是进度。 HTH。
[1] 此一般领域中的相当多 API 已被弃用,并且虽然引入了一些新 API,但它们似乎不完整。合理猜测可能会在 10.9 中出现更多...
关于cocoa - 如何替换 10.8 中已弃用的 FSFileOperationCreate?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12438835/