gpt4 book ai didi

ios - 我的文件存在,但 fileExistsAtPath 总是返回 false

转载 作者:行者123 更新时间:2023-11-28 11:04:10 35 4
gpt4 key购买 nike

我正在使用以下代码来检测文件是否存在。该文件确实存在,但 fileExistsAtPath 始终返回 false

 if let receiptFound = receiptUrl?.checkResourceIsReachableAndReturnError(error){
print("receiptUrl is \(receiptUrl?.path)") }

print("Does the file exist \(NSFileManager.defaultManager().fileExistsAtPath(receiptUrl!.path!))")

if NSFileManager.defaultManager().fileExistsAtPath(receiptUrl!.path!)


{ //work with file
}

我的输出是:

enter image description here

我不明白为什么当文件存在时语句返回为false?

最佳答案

在我看来,您正在处理的 URL 不在应用程序沙箱内。

您的应用只能访问非常有限的目录(应用包的一部分、文档、缓存和其他一些文件夹)。文件管理器可能无权访问 StoreKit 目录,因此函数 fileExistsAtPath 返回 false。

编辑

请注意,路径的开头是 /private。这强烈表明像您这样的第三方应用无法访问该文件。

关于ios - 我的文件存在,但 fileExistsAtPath 总是返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39181034/

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