gpt4 book ai didi

ios - 创建目录和调用 setResourceValue 的正确位置在哪里?

转载 作者:行者123 更新时间:2023-11-30 13:34:47 30 4
gpt4 key购买 nike

我尝试创建一些目录并将其从 iCloud 备份中排除:

// create directory - someDir 
NSFileManager.defaultManager().createDirectoryAtURL(someDir, withIntermediateDirectories: true, attributes: nil)

// set the directory to be excluded from iCloud backup
someDir.setResourceValue(true, forKey: NSURLIsExcludedFromBackupKey)

我正在考虑将代码放在 AppDelegate.swiftapplication:didFinishLaunchingWithOptions 中,正确吗?

放置代码的正确位置(创建目录和 setResourceValue)在哪里?

最佳答案

如果您的应用程序在运行时需要此目录,那么您应该在 didFinishLaunchingWithOptions 中添加代码来创建它。检查该目录是否已存在,如果不存在,则创建它。我以前在应用程序中做过这样的事情,并且这些应用程序已经运行了一年多。

我建议创建或使用一个单独的类,您可以在其中放置所有代码详细信息,然后从 didFinishLaunchingWithOptions 中调用 if 。这使得 AppDelegate 中的代码最少。

关于ios - 创建目录和调用 setResourceValue 的正确位置在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36204653/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com