OGeek|极客世界-中国程序员成长平台

标题: ios - 等到操作完成 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 22:00
标题: ios - 等到操作完成

我需要等到文件移动到新位置才能使用它。

在模拟器中,此代码运行速度很快,并且在我开始使用之前将文件移动到新位置,但在真实设备上则不然。

我尝试使用 @synchronized 但似乎不是正确的工具。

有什么建议吗?

        NSURL *newurl = [[legacyPersistentStoreURL  URLByDeletingPathExtension] URLByAppendingPathExtension"guide"];
        NSURL *desturl = [newurl URLByAppendingPathComponent"StoreContent"];
        [[NSFileManager defaultManager] createDirectoryAtURL:desturl withIntermediateDirectories:YES attributes:nil error:NULL];
        NSURL *finalurl = [desturl URLByAppendingPathComponent"persistentStore"];
        [fileManager moveItemAtURL:legacyPersistentStoreURL toURL:finalurl error:NULL];



Best Answer-推荐答案


这个方法可能有帮助

- (void)performSelectorOnMainThreadSEL)aSelector withObjectid)arg waitUntilDoneBOOL)wait;

关于ios - 等到操作完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9682269/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4